update command for updating repository format

This commit is contained in:
Fabien Benureau 2013-06-25 23:09:26 +02:00
parent 4f132737e4
commit 4e6b062a64
3 changed files with 21 additions and 0 deletions

View File

@ -10,3 +10,4 @@ import remove_cmd
import websearch_cmd
import tags_cmd
import attach_cmd
import update_cmd

View File

@ -0,0 +1,19 @@
from .. import repo
from .. import color
def parser(subparsers, config):
parser = subparsers.add_parser('update', help='update the repository to the lastest format')
return parser
def command(config, ui):
rp = repo.Repository.from_directory(config)
msg = ("You should backup the paper directory {} before continuing."
"Continue ?").format(color.dye(rp.papersdir, color.filepath))
sure = ui.input_yn(question=msg, default='n')
if sure:
for p in rp.all_papers():
tags = set(p.metadata['tags'])
tags = tags.union(p.metadata['labels'])
p.metadata.pop('labels', [])
rp.save_paper(p)

View File

@ -22,6 +22,7 @@ cmds = collections.OrderedDict([
('websearch', commands.websearch_cmd),
('tags', commands.tags_cmd),
('attach', commands.attach_cmd),
('update', commands.update_cmd),
])
config = configs.read_config()