missed two somehow
This commit is contained in:
parent
5cc3f892a0
commit
23890bf579
@ -1,13 +1,13 @@
|
|||||||
from .. import repo
|
from .. import repo
|
||||||
from .. import color
|
from .. import color
|
||||||
from ..uis import get_ui
|
from ..uis import get_ui
|
||||||
|
from ..utils import resolve_citekey_list
|
||||||
|
|
||||||
def parser(subparsers):
|
def parser(subparsers):
|
||||||
parser = subparsers.add_parser('remove', help='removes a paper')
|
parser = subparsers.add_parser('remove', help='removes a publication')
|
||||||
parser.add_argument('-f', '--force', action='store_true', default=None,
|
parser.add_argument('-f', '--force', action='store_true', default=None,
|
||||||
help="does not prompt for confirmation.")
|
help="does not prompt for confirmation.")
|
||||||
parser.add_argument('citekeys', nargs='*',
|
parser.add_argument('citekeys', nargs='+',
|
||||||
help="one or several citekeys")
|
help="one or several citekeys")
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
@ -18,15 +18,23 @@ def command(conf, args):
|
|||||||
force = args.force
|
force = args.force
|
||||||
rp = repo.Repository(conf)
|
rp = repo.Repository(conf)
|
||||||
|
|
||||||
|
keys = resolve_citekey_list(repo=rp, citekeys=args.citekeys, ui=ui, exit_on_fail=True)
|
||||||
|
|
||||||
if force is None:
|
if force is None:
|
||||||
are_you_sure = (("Are you sure you want to delete paper(s) [{}]"
|
are_you_sure = (("Are you sure you want to delete the publication(s) [{}]"
|
||||||
" (this will also delete associated documents)?")
|
" (this will also delete associated documents)?")
|
||||||
.format(', '.join([color.dye_out(c, 'citekey') for c in args.citekeys])))
|
.format(', '.join([color.dye_out(c, 'citekey') for c in args.citekeys])))
|
||||||
sure = ui.input_yn(question=are_you_sure, default='n')
|
sure = ui.input_yn(question=are_you_sure, default='n')
|
||||||
if force or sure:
|
if force or sure:
|
||||||
for c in args.citekeys:
|
for c in keys:
|
||||||
|
try:
|
||||||
rp.remove_paper(c)
|
rp.remove_paper(c)
|
||||||
ui.message('The paper(s) [{}] were removed'.format(', '.join([color.dye_out(c, 'citekey') for c in args.citekeys])))
|
except Exception as e:
|
||||||
|
ui.error(e.message)
|
||||||
|
ui.message('The publication(s) [{}] were removed'.format(
|
||||||
|
', '.join([color.dye_out(c, 'citekey') for c in keys])))
|
||||||
# FIXME: print should check that removal proceeded well.
|
# FIXME: print should check that removal proceeded well.
|
||||||
else:
|
else:
|
||||||
ui.message('The paper(s) [{}] were *not* removed'.format(', '.join([color.dye_out(c, 'citekey') for c in args.citekeys])))
|
ui.message('The publication(s) [{}] were {} removed'.format(
|
||||||
|
', '.join([color.dye_out(c, 'citekey') for c in keys]),
|
||||||
|
color.dye_out('not','bold')))
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
from ..uis import get_ui
|
from ..uis import get_ui
|
||||||
from .. import bibstruct
|
|
||||||
from .. import content
|
|
||||||
from .. import repo
|
from .. import repo
|
||||||
from .. import paper
|
from ..utils import resolve_citekey
|
||||||
|
|
||||||
def parser(subparsers):
|
def parser(subparsers):
|
||||||
parser = subparsers.add_parser('rename', help='rename the citekey of a repository')
|
parser = subparsers.add_parser('rename', help='rename the citekey of a repository')
|
||||||
@ -22,5 +20,10 @@ def command(conf, args):
|
|||||||
ui = get_ui()
|
ui = get_ui()
|
||||||
rp = repo.Repository(conf)
|
rp = repo.Repository(conf)
|
||||||
|
|
||||||
paper = rp.pull_paper(args.citekey)
|
# TODO: here should be a test whether the new citekey is valid
|
||||||
|
try:
|
||||||
|
key = resolve_citekey(repo=rp, citekey=args.citekey, ui=ui, exit_on_fail=True)
|
||||||
|
paper = rp.pull_paper(key)
|
||||||
rp.rename_paper(paper, args.new_citekey)
|
rp.rename_paper(paper, args.new_citekey)
|
||||||
|
except Exception as e:
|
||||||
|
ui.error(e.message)
|
Loading…
x
Reference in New Issue
Block a user