Skip to content

Commit

Permalink
Merge pull request #57 from dcchambers/feat/list-notes
Browse files Browse the repository at this point in the history
Feat: Add ability to list notes
  • Loading branch information
dcchambers committed Nov 11, 2021
2 parents 9e94b19 + 1ac7752 commit c171e75
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ and will open that note file in Vim.
- Use the `-d` flag to move a file into trash (`$NOTE_DIR/trash`)
- `--destroy <FILENAME>`
- Use the `--destroy` flag to permanently delete a note.
- `-l | --list [<FILE EXTENSION>]`
- Use this `--list` flag to list note files. Defaults to `.md` files if no extension is specified.

## Demo (Asciinema)

Expand Down
17 changes: 16 additions & 1 deletion note.bash
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ create_note() {
}

print_help() {
printf "Notekeeper 1.1 (11 May 2021)
printf "Notekeeper 1.2 (10 November 2021)
Usage: note [<args>]
Expand All @@ -50,6 +50,8 @@ Arguments:
-t | --time Add a timestamp when opening a note.
-d | --delete <FILENAME> Move a note to the trash directory.
--destroy <FILENAME> Permanently delete (rm) a note.
-l | --list [<File Extension>] List note files. Defaults to .md files
if no file extension is specified.
Notekeeper loads configuration variables from:
\$HOME/.config/notekeeper/noterc.
Expand Down Expand Up @@ -133,6 +135,10 @@ destroy_note() {
fi
}

list_notes() {
find "$BASE_NOTE_DIR" -type f -name "*$1" | sed "s@.*/@@" | sort
}

openNote=false
printNoteOnly=false
createNoteOnly=false
Expand Down Expand Up @@ -201,6 +207,15 @@ if (($# > 0)); then
destroy_note "$2"
exit 0
;;
-l | --list)
if [ "$#" -eq 2 ]; then
file_extension=$2
else
file_extension=".md"
fi
list_notes $file_extension
exit 0
;;
*)
printf "Unknown Argument \"%s\"\n" "$1"
printf "Use \"note --help\" to see usage information.\n"
Expand Down

0 comments on commit c171e75

Please sign in to comment.