Adds remove command.
This commit is contained in:
parent
411647a1b3
commit
a45051815d
@ -6,4 +6,5 @@ import init_cmd
|
||||
import list_cmd
|
||||
import open_cmd
|
||||
import edit_cmd
|
||||
import remove_cmd
|
||||
import websearch_cmd
|
||||
|
20
papers/commands/remove_cmd.py
Normal file
20
papers/commands/remove_cmd.py
Normal file
@ -0,0 +1,20 @@
|
||||
from .. import repo
|
||||
|
||||
|
||||
def parser(subparsers, config):
|
||||
parser = subparsers.add_parser('remove', help='removes a paper')
|
||||
parser.add_argument('reference',
|
||||
help='reference to the paper (citekey or number)')
|
||||
return parser
|
||||
|
||||
|
||||
def command(config, ui, reference):
|
||||
rp = repo.Repository.from_directory()
|
||||
key = rp.citekey_from_ref(reference, fatal=True)
|
||||
paper = rp.paper_from_citekey(key)
|
||||
are_you_sure = ("Are you sure you want to delete paper [%s]"
|
||||
" (this will also delete associated documents)?"
|
||||
% ui.colored(paper.citekey, color='citekey'))
|
||||
sure = ui.input_yn(question=are_you_sure, default='n')
|
||||
if sure:
|
||||
rp.remove(paper.citekey)
|
@ -17,6 +17,7 @@ cmds = collections.OrderedDict([
|
||||
('export', commands.export_cmd),
|
||||
('list', commands.list_cmd),
|
||||
('edit', commands.edit_cmd),
|
||||
('remove', commands.remove_cmd),
|
||||
('open', commands.open_cmd),
|
||||
('websearch', commands.websearch_cmd)
|
||||
])
|
||||
|
Loading…
x
Reference in New Issue
Block a user