Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to set an recur of none #256

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions ultralist/input_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,17 @@ func (p *InputParser) Parse(input string) (*Filter, error) {
filter.HasRecur = true
filter.Recur = r.FindString(word)[6:]

if filter.Recur == "none" {
filter.Recur = ""
}

r := &Recurrence{}

if !r.ValidRecurrence(filter.Recur) {
return filter, fmt.Errorf("I could not understand the recurrence you gave me: '%s'", filter.Recur)
}

// a Recur of none is "" in the Todo store, lets set that now
if filter.Recur == "none" {
filter.Recur = ""
}

}

r, _ = regexp.Compile(`until:.*$`)
Expand Down
2 changes: 2 additions & 0 deletions ultralist/recurrence.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const (
Weekly = "weekly"
Monthly = "monthly"
Yearly = "yearly"
None = "none"
)

// Recurrence struct contains the logic for dealing with recurring todos.
Expand All @@ -19,6 +20,7 @@ type Recurrence struct{}
func (r *Recurrence) ValidRecurrence(input string) bool {
switch input {
case
None,
Daily,
Weekdays,
Weekly,
Expand Down