From 3b15e2a0432c96e3cf96555bbdf1c12a562b5921 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Fri, 9 Mar 2018 16:29:48 +0100 Subject: Add --delete option for import --- bibtool/cli.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bibtool/cli.py b/bibtool/cli.py index 74855b9..8f29588 100644 --- a/bibtool/cli.py +++ b/bibtool/cli.py @@ -22,7 +22,8 @@ def cli(): @cli.command('import') @click.argument('filename', type=TYPE_FILE) @click.option('--directory', type=TYPE_DIR, default=os.getcwd()) -def _import(filename, directory): +@click.option('--delete/--no-delete', default=False) +def _import(filename, directory, delete): bibtex_data = bibtool.extract.get_bibtex_data(filename) if not bibtex_data.entries: @@ -57,3 +58,7 @@ def _import(filename, directory): shutil.copy(filename, outfilename) click.echo('Added {} to the repository.'.format(entry['ID'])) + + if delete: + os.remove(filename) + click.echo('Deleted {}.'.format(filename)) -- cgit v1.2.3