diff options
-rw-r--r-- | src/lib/note_list.cpp | 18 | ||||
-rw-r--r-- | src/lib/note_list.h | 1 | ||||
-rw-r--r-- | src/main.cpp | 11 |
3 files changed, 30 insertions, 0 deletions
diff --git a/src/lib/note_list.cpp b/src/lib/note_list.cpp index 9bbc939..73f20b9 100644 --- a/src/lib/note_list.cpp +++ b/src/lib/note_list.cpp @@ -108,6 +108,24 @@ vector<string> note_list::enum_names() { } /** + * Returns the contents of the requested note + * + * @param string note_name Name of the note to get the contents for + * + * @return vector<string> Contents of the note, broken per line into a vector. + */ +vector<string> note_list::cat_note( string note_name ) { + // Check for the requested note + for( int i = 0; i < notes.size(); i++ ) { + if( notes[i].friendly_name() == note_name ) { + // Read in the note's contents + notes[i].read(); + return notes[i].body; + } + } +} + +/** * TODO */ vector<string> note_list::find( bool case_sensitive, string term ) { diff --git a/src/lib/note_list.h b/src/lib/note_list.h index 9d74045..fd2fb4b 100644 --- a/src/lib/note_list.h +++ b/src/lib/note_list.h @@ -39,5 +39,6 @@ class note_list { void edit( string, string ); vector<string> enum_names(); vector<string> find( bool, string ); + vector<string> cat_note( string ); }; #endif diff --git a/src/main.cpp b/src/main.cpp index a2c5bb7..ee8dbee 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,6 +21,7 @@ using namespace std; #include "lib/config.h" #include "lib/note.h" #include "lib/note_list.h" +#include "lib/file.h" void get_help() { string out = "Noteless provides a simple command line interface for note" @@ -57,6 +58,13 @@ void search_notes( note_list list, string term ) { } } +void cat_note( note_list list, string name ) { + vector<string> body = list.cat_note( name ); + for( int i = 0; i < body.size(); i++ ) { + cout << body[i] << endl; + } +} + /** * Helper function to determine which editor to use. Order or priority is * config file, environmental variable, default. @@ -121,6 +129,9 @@ int main( int argc, char** argv ) { } else if( arg == "find" ) { string term = argv[i + 1]; search_notes( list, term ); + } else if( arg == "cat" ) { + string name = argv[i + 1]; + cat_note( list, name ); } else if( arg == "help" ) { get_help(); } |