Skip to content

Commit

Permalink
Usage improvements & bug fixes
Browse files Browse the repository at this point in the history
`note` command:
  - Add flag title as option to define note title

`note show` command:
  - Fix bug when no note is found

`note edit` command:
  - Fix bug when no note is found

`note delete` command:
  - Fix bug when no note is found
  - Ask for confirmation to delete note
  - Add flag option yes to delete command
  • Loading branch information
Rafael Gumieri committed Apr 25, 2018
1 parent bddfcb1 commit 54bfbf1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions cmd/deleteNote.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ func DeleteNote(context *cli.Context) {
noteToFind := strings.Join(context.Args()[:], " ")

notesFound := fuzzy.RankFind(noteToFind, notesNames)

if len(notesFound) == 0 {
os.Exit(1)
}

noteFound := notesFound[0].Target

confirmMessage := fmt.Sprintf("Do you want to delete the note %s ?", noteFound)
Expand Down
5 changes: 5 additions & 0 deletions cmd/editNote.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ func EditNote(context *cli.Context) {
noteToFind := strings.Join(context.Args()[:], " ")

notesFound := fuzzy.RankFind(noteToFind, notesNames)

if len(notesFound) == 0 {
os.Exit(1)
}

noteFound := notesFound[0].Target

err = editor.File(viper.GetString("editor"), filepath.Join(notePath, noteFound))
Expand Down
5 changes: 5 additions & 0 deletions cmd/showNote.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ func ShowNote(context *cli.Context) {
noteToFind := strings.Join(context.Args()[:], " ")

notesFound := fuzzy.RankFind(noteToFind, notesNames)

if len(notesFound) == 0 {
os.Exit(1)
}

noteFound := notesFound[0].Target

noteContent, err := ioutil.ReadFile(filepath.Join(notePath, noteFound))
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func main() {

app.Name = "Note"

app.Version = "0.0.4"
app.Version = "0.0.5"

app.Usage = "Quick and easy Command-line tool for taking notes"
app.UsageText = "note [just type a text] [or command] [with command options]"
Expand Down

0 comments on commit 54bfbf1

Please sign in to comment.