From 3bbfd0f3882a3832fb2affaa6d2a8aff2fedc6ba Mon Sep 17 00:00:00 2001 From: Aaron Ball Date: Tue, 24 Feb 2015 12:20:56 -0700 Subject: Added support for "cmd not found searching notes" When a command is given to noteless and it doesn't match any commands, a fuzzy search through the note names is now performed. If one of the note names matches the "unknown command" argument, the note is opened for editing. This is effectively the default behavior (edit) if a command is not specified. --- src/main.c | 6 +++--- src/note_list.c | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main.c b/src/main.c index e6d3728..6a2d170 100644 --- a/src/main.c +++ b/src/main.c @@ -187,9 +187,9 @@ int main(int argc, char* argv[]) { // return cat_note( list, name ); } else if(strcmp(argv[1], "help") == 0) { get_help(); - // } else if( list.find_note_id( arg ) != -1 ) { - // // Try to open the note if it exists - // return list.edit( editor, arg ); + } else if(note_list_get_note_id(&list, argv[1]) != -1 ) { + // Try to open the note if it exists + return note_list_edit(&list, editor, argv[1]); } else { printf("Error: Unknown command or note name '%s'.\n", argv[1]); return 1; diff --git a/src/note_list.c b/src/note_list.c index 638d631..bcfd1e0 100644 --- a/src/note_list.c +++ b/src/note_list.c @@ -178,7 +178,6 @@ int note_list_edit(note_list_t* list, char* editor, char* note_name) { strcat(path, list->names[id]); strcat(path, "."); strcat(path, list->extension); - printf("%s\n", path); note_t note; note_new(¬e, path); -- cgit v1.2.3