Skip to content

Commit

Permalink
rename parser -> note_parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Grant Ammons committed Aug 27, 2020
1 parent a13a93d commit b64d21f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ultralist/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func (a *App) HandleNotes(input string) {
fmt.Println("No such id.")
return
}
parser := &Parser{}
parser := &NoteParser{}

if parser.ParseAddNote(todo, input) {
fmt.Println("Note added.")
Expand Down
14 changes: 7 additions & 7 deletions ultralist/parser.go → ultralist/note_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"strconv"
)

// Parser is a legacy class that parses various
type Parser struct{}
// NoteParser is a legacy class that parses various
type NoteParser struct{}

// ParseAddNote is adding a note to an todo.
func (p *Parser) ParseAddNote(todo *Todo, input string) bool {
func (p *NoteParser) ParseAddNote(todo *Todo, input string) bool {
r, _ := regexp.Compile(`^an\s+\d+\s+(.*)`)
matches := r.FindStringSubmatch(input)
if len(matches) != 2 {
Expand All @@ -22,7 +22,7 @@ func (p *Parser) ParseAddNote(todo *Todo, input string) bool {
}

// ParseDeleteNote is deleting a note from an todo.
func (p *Parser) ParseDeleteNote(todo *Todo, input string) bool {
func (p *NoteParser) ParseDeleteNote(todo *Todo, input string) bool {
r, _ := regexp.Compile(`^dn\s+\d+\s+(\d+)`)
matches := r.FindStringSubmatch(input)
if len(matches) != 2 {
Expand All @@ -44,7 +44,7 @@ func (p *Parser) ParseDeleteNote(todo *Todo, input string) bool {
}

// ParseEditNote is editing a note from an todo.
func (p *Parser) ParseEditNote(todo *Todo, input string) bool {
func (p *NoteParser) ParseEditNote(todo *Todo, input string) bool {
r, _ := regexp.Compile(`^en\s+\d+\s+(\d+)\s+(.*)`)
matches := r.FindStringSubmatch(input)
if len(matches) != 3 {
Expand All @@ -66,7 +66,7 @@ func (p *Parser) ParseEditNote(todo *Todo, input string) bool {
}

// ParseShowNote is defining if notes should be shown or not.
func (p *Parser) ParseShowNote(todo *Todo, input string) bool {
func (p *NoteParser) ParseShowNote(todo *Todo, input string) bool {
r, _ := regexp.Compile(`^n\s+\d+`)
matches := r.FindStringSubmatch(input)
if len(matches) != 1 {
Expand All @@ -75,7 +75,7 @@ func (p *Parser) ParseShowNote(todo *Todo, input string) bool {
return true
}

func (p *Parser) getNoteID(input string) (int, error) {
func (p *NoteParser) getNoteID(input string) (int, error) {
ret, err := strconv.Atoi(input)
if err != nil {
fmt.Println("wrong note id")
Expand Down

0 comments on commit b64d21f

Please sign in to comment.