Skip to content

Commit

Permalink
return of the agenda command (#226)
Browse files Browse the repository at this point in the history
Co-authored-by: Grant Ammons <[email protected]>
  • Loading branch information
gammons and Grant Ammons authored Oct 21, 2020
1 parent 8ef6bc7 commit 1c034a5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ultralist/date_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (dp *DateParser) ParseDate(dateString string, pivotDay time.Time) (date tim
return bod(pivotDay).AddDate(0, 0, -1), nil
case "today", "tod":
return bod(pivotDay), nil
case "tomorrow", "tom":
case "tomorrow", "tom", "agenda":
return bod(pivotDay).AddDate(0, 0, 1), nil
case "monday", "mon":
return dp.monday(pivotDay), nil
Expand Down
9 changes: 8 additions & 1 deletion ultralist/input_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func (p *InputParser) Parse(input string) (*Filter, error) {
r, _ = regexp.Compile(`due:.*$`)
if r.MatchString(word) {
filter.HasDue = true

dueDate, err := dateParser.ParseDate(r.FindString(word)[4:], time.Now())
if err != nil {
return filter, err
Expand All @@ -110,7 +111,13 @@ func (p *InputParser) Parse(input string) (*Filter, error) {
if dueDate.IsZero() {
filter.Due = ""
} else {
filter.Due = dueDate.Format(DATE_FORMAT)
if word == "due:agenda" {
filter.HasDueBefore = true
filter.HasDue = false
filter.DueBefore = dueDate.Format(DATE_FORMAT)
} else {
filter.Due = dueDate.Format(DATE_FORMAT)
}
}
match = true
}
Expand Down
12 changes: 12 additions & 0 deletions ultralist/input_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ func TestSubject(t *testing.T) {
assert.Equal(tomorrow, filter.Due)
}

func TestDueAgenda(t *testing.T) {
assert := assert.New(t)
parser := &InputParser{}

filter, _ := parser.Parse("due:agenda blah blah")

tomorrow := time.Now().AddDate(0, 0, 1).Format(DATE_FORMAT)
assert.Equal(tomorrow, filter.DueBefore)
assert.Equal(true, filter.HasDueBefore)
assert.Equal(false, filter.HasDue)
}

func TestProjectsInSubject(t *testing.T) {
assert := assert.New(t)
parser := &InputParser{}
Expand Down

0 comments on commit 1c034a5

Please sign in to comment.