commit d45698defc78ce00f16c1964a596c49104c559b1
parent 1b16f7ff7b66c93cebdcd392b4469225354fc00d
Author: Daniel Moch <daniel@danielmoch.com>
Date: Mon, 30 Jul 2018 20:54:05 -0400
CLI commands working.
Diffstat:
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/nnotes_cli/nncli.py b/nnotes_cli/nncli.py
@@ -124,6 +124,9 @@ def exec_cmd_on_note(self, note, cmd=None, raw=False):
# focus position will fail if no notes available (listbox empty)
# TODO: find a neater way to check than try/except
pass
+ except AttributeError:
+ # we're running in CLI mode
+ pass
subs = {
'fname': fname,
@@ -959,7 +962,7 @@ def cli_list_notes(self, regex, search_string):
sort_mode=self.config.get_config('sort_mode'))
for n in note_list:
flags = utils.get_note_flags(n.note)
- print((n.key + \
+ print((str(n.key) + \
' [' + flags + '] ' + \
utils.get_note_title(n.note)))
@@ -980,7 +983,7 @@ def cli_note_dump(self, key):
print(sep)
print(('| {:<' + str(w) + '} |').format((' Title: ' + title)[:w]))
- print(('| {:<' + str(w) + '} |').format((' Key: ' + note.get('id', 'Localkey: {}'.format(note.get('localkey'))))[:w]))
+ print(('| {:<' + str(w) + '} |').format((' Key: ' + str(note.get('id', 'Localkey: {}'.format(note.get('localkey'))))[:w])))
print(('| {:<' + str(w) + '} |').format((' Date: ' + mod_time)[:w]))
print(('| {:<' + str(w) + '} |').format((' Category: ' + category)[:w]))
print(('| {:<' + str(w) + '} |').format((' Flags: [' + flags + ']')[:w]))
@@ -1122,7 +1125,7 @@ def cli_note_category_rm(self, key):
old_category = self.cli_note_category_get(key)
if old_category:
- self.cli_note_category_set(key, None)
+ self.cli_note_category_set(key, '')
def SIGINT_handler(signum, frame):
print('\nSignal caught, bye!')
@@ -1190,7 +1193,10 @@ def main(argv=sys.argv[1:]):
elif opt in [ '-r', '--regex']:
regex = True
elif opt in [ '-k', '--key']:
- key = arg
+ try:
+ key = int(arg)
+ except:
+ print('ERROR: Key specified with -k must be an integer')
elif opt in [ '-t', '--title']:
title = arg
elif opt in [ '-c', '--config']:
diff --git a/todo.txt b/todo.txt
@@ -1 +0,0 @@
-1. Command line