diff options
-rw-r--r-- | lesana/command.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lesana/command.py b/lesana/command.py index e900aad..2beb88b 100644 --- a/lesana/command.py +++ b/lesana/command.py @@ -1,3 +1,7 @@ +import logging +import os +import subprocess + import gadona from . import Collection, Entry @@ -14,6 +18,19 @@ class New(gadona.Command): collection = Collection(self.settings.collection) new_entry = Entry(collection) collection.save_entries([new_entry]) + filepath = os.path.join( + collection.basedir, + 'items', + new_entry.fname + ) + try: + subprocess.call(['sensible-editor', filepath]) + except FileNotFoundError as e: + logging.warning( + "Could not open new file with editor: {}".format(str(e)) + ) + else: + collection.update_cache([filepath]) print(new_entry.fname) |