Remove ask confirmation + force mode.
This commit is contained in:
parent
44f61fb810
commit
330532fd82
@ -64,6 +64,8 @@ class TexnotePlugin(PapersPlugin):
|
|||||||
# remove
|
# remove
|
||||||
p = sub.add_parser('remove', help='remove a reference')
|
p = sub.add_parser('remove', help='remove a reference')
|
||||||
add_references_argument(p, single=True)
|
add_references_argument(p, single=True)
|
||||||
|
p.add_argument('-f', '--force', action='store_true',
|
||||||
|
help='do not ask for confirmation', default=False)
|
||||||
# edit
|
# edit
|
||||||
p = sub.add_parser('edit', help='edit the reference texnote')
|
p = sub.add_parser('edit', help='edit the reference texnote')
|
||||||
p.add_argument('-v', '--view', action='store_true',
|
p.add_argument('-v', '--view', action='store_true',
|
||||||
@ -158,9 +160,14 @@ class TexnotePlugin(PapersPlugin):
|
|||||||
def create(self, citekey):
|
def create(self, citekey):
|
||||||
self._autofill_texfile(citekey)
|
self._autofill_texfile(citekey)
|
||||||
|
|
||||||
def remove(self, reference):
|
def remove(self, reference, force=False):
|
||||||
rp = repo.Repository(config())
|
rp = repo.Repository(config())
|
||||||
citekey = parse_reference(rp, reference)
|
citekey = parse_reference(rp, reference)
|
||||||
|
if not force:
|
||||||
|
ui = get_ui()
|
||||||
|
are_you_sure = 'Are you sure you want to delete [{}]'.format(citekey)
|
||||||
|
sure = ui.input_yn(question=are_you_sure, default='n')
|
||||||
|
if force or sure:
|
||||||
os.remove(self.get_texfile(citekey))
|
os.remove(self.get_texfile(citekey))
|
||||||
|
|
||||||
def rename(self, old_citekey, new_citekey, overwrite=False):
|
def rename(self, old_citekey, new_citekey, overwrite=False):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user