diff options
author | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2016-12-21 09:54:41 +0100 |
---|---|---|
committer | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2016-12-21 09:54:41 +0100 |
commit | 8ccc34fb6d167ab9b142df40e515a89770523323 (patch) | |
tree | 27f130c7b1c4e9e0af2497d760e410cc95f911a1 | |
parent | 24f720801ece36ab13c6acc159b7cb0d05136840 (diff) |
Run sensible-editor to fill in newly created entries.
-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) |