summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bibtool/cli.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/bibtool/cli.py b/bibtool/cli.py
index 3056933..43d6c21 100644
--- a/bibtool/cli.py
+++ b/bibtool/cli.py
@@ -35,13 +35,16 @@ def _import(filename, directory, delete):
click.echo('Found one Bibtex entry: ' + entry['ID'])
if click.confirm('Do you want to edit the entry?'):
edited_data = click.edit(bibtexparser.dumps(bibtex_data),
- extension='.bib')
- if edited_data:
- bibtex_data = bibtexparser.loads(edited_data)
- if len(bibtex_data.entries) != 1:
- raise Exception('The edited data must contain exactly one'
- 'Bibtex entry.')
- entry = bibtex_data.entries[0]
+ extension='.bib', require_save=None)
+ if not edited_data:
+ click.echo('Empty Bibtex data. Aborting.')
+ return
+
+ bibtex_data = bibtexparser.loads(edited_data)
+ if len(bibtex_data.entries) != 1:
+ raise Exception('The edited data must contain exactly one '
+ 'Bibtex entry.')
+ entry = bibtex_data.entries[0]
click.confirm('Add {} to the repository?'.format(entry['ID']),
default=True, abort=True)