Compare commits
2 Commits
05ad2aa0f0
...
ac4311d542
Author | SHA1 | Date |
---|---|---|
Erik Winter | ac4311d542 | |
Erik Winter | 15b6958248 |
|
@ -56,7 +56,7 @@ func (la ListArgs) Parse(main []string, fields map[string]string) (Command, erro
|
||||||
fields["from"] = today.String()
|
fields["from"] = today.String()
|
||||||
fields["to"] = today.Add(7).String()
|
fields["to"] = today.Add(7).String()
|
||||||
case main[0] == "recur":
|
case main[0] == "recur":
|
||||||
fields["recurring"] = "true"
|
fields["recurrer"] = "true"
|
||||||
// case main[0] == "list":
|
// case main[0] == "list":
|
||||||
// fields["from"] = today.String()
|
// fields["from"] = today.String()
|
||||||
// fields["to"] = today.String()
|
// fields["to"] = today.String()
|
||||||
|
|
|
@ -37,10 +37,20 @@ func NewUpdateArgs() UpdateArgs {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ua UpdateArgs) Parse(main []string, fields map[string]string) (Command, error) {
|
func (ua UpdateArgs) Parse(main []string, fields map[string]string) (Command, error) {
|
||||||
if len(main) < 2 || main[0] != "update" {
|
if len(main) < 2 {
|
||||||
return nil, ErrWrongCommand
|
return nil, ErrWrongCommand
|
||||||
}
|
}
|
||||||
localID, err := strconv.Atoi(main[1])
|
aliases := []string{"u", "update"}
|
||||||
|
var localIDStr string
|
||||||
|
switch {
|
||||||
|
case slices.Contains(aliases, main[0]):
|
||||||
|
localIDStr = main[1]
|
||||||
|
case slices.Contains(aliases, main[1]):
|
||||||
|
localIDStr = main[0]
|
||||||
|
default:
|
||||||
|
return nil, ErrWrongCommand
|
||||||
|
}
|
||||||
|
localID, err := strconv.Atoi(localIDStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("not a local id: %v", main[1])
|
return nil, fmt.Errorf("not a local id: %v", main[1])
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ func (t *SqliteTask) FindMany(params storage.TaskListParams) ([]item.Task, error
|
||||||
where := make([]string, 0)
|
where := make([]string, 0)
|
||||||
var dateNonEmpty bool
|
var dateNonEmpty bool
|
||||||
if params.HasRecurrer {
|
if params.HasRecurrer {
|
||||||
where[0] = `recurrer != ''`
|
where = append(where, `recurrer != ''`)
|
||||||
}
|
}
|
||||||
if !params.From.IsZero() {
|
if !params.From.IsZero() {
|
||||||
where = append(where, `date >= ?`)
|
where = append(where, `date >= ?`)
|
||||||
|
|
Loading…
Reference in New Issue