summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Krahl <me@robin-krahl.de>2018-03-09 16:29:48 +0100
committerRobin Krahl <me@robin-krahl.de>2018-03-09 16:29:48 +0100
commit3b15e2a0432c96e3cf96555bbdf1c12a562b5921 (patch)
tree8e92110fcbb26daa14bca10b22f691a8a0843565
parent5be2e9ae50f9358d16f14e09c2e7d51ec1dc8755 (diff)
downloadbibtool-3b15e2a0432c96e3cf96555bbdf1c12a562b5921.tar.gz
bibtool-3b15e2a0432c96e3cf96555bbdf1c12a562b5921.tar.bz2
Add --delete option for import
-rw-r--r--bibtool/cli.py7
1 files changed, 6 insertions, 1 deletions
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))