summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2016-12-21 09:54:41 +0100
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2016-12-21 09:54:41 +0100
commit8ccc34fb6d167ab9b142df40e515a89770523323 (patch)
tree27f130c7b1c4e9e0af2497d760e410cc95f911a1
parent24f720801ece36ab13c6acc159b7cb0d05136840 (diff)
Run sensible-editor to fill in newly created entries.
-rw-r--r--lesana/command.py17
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)