update command for updating repository format
This commit is contained in:
parent
4f132737e4
commit
4e6b062a64
@ -10,3 +10,4 @@ import remove_cmd
|
||||
import websearch_cmd
|
||||
import tags_cmd
|
||||
import attach_cmd
|
||||
import update_cmd
|
||||
|
19
papers/commands/update_cmd.py
Normal file
19
papers/commands/update_cmd.py
Normal 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)
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user