Archive by context/project
This commit is contained in:
parent
b0d4cfe017
commit
cc75725d66
41
timer_ops.go
41
timer_ops.go
@ -239,6 +239,42 @@ func (a *AppState) opArchiveTimer(args []string) int {
|
|||||||
var id int
|
var id int
|
||||||
var timer *timertxt.Timer
|
var timer *timertxt.Timer
|
||||||
var err error
|
var err error
|
||||||
|
if strings.HasPrefix(v, "@") {
|
||||||
|
// We're archiving by context
|
||||||
|
v = strings.TrimPrefix(v, "@")
|
||||||
|
fmt.Println("Archiving by context:", v)
|
||||||
|
timers := a.TimerList.GetTimersWithContext(v)
|
||||||
|
fmt.Println("Found timers: ", len(*timers))
|
||||||
|
for _, tmr := range *timers {
|
||||||
|
if tmr.Finished {
|
||||||
|
if err = a.archiveTimer(tmr.Id); err != nil {
|
||||||
|
fmt.Printf("Error archiving timer %d\n", tmr.Id)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
fmt.Println(a.getDoneTimerString(tmr))
|
||||||
|
} else {
|
||||||
|
fmt.Println("Refusing to archive running timer:", tmr.Id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if strings.HasPrefix(v, "+") {
|
||||||
|
// We're archiving by projcet
|
||||||
|
v = strings.TrimPrefix(v, "+")
|
||||||
|
fmt.Println("Archiving by project:", v)
|
||||||
|
timers := a.TimerList.GetTimersWithProject(v)
|
||||||
|
fmt.Println("Found timers: ", len(*timers))
|
||||||
|
for _, tmr := range *timers {
|
||||||
|
if tmr.Finished {
|
||||||
|
if err = a.archiveTimer(tmr.Id); err != nil {
|
||||||
|
fmt.Printf("Error archiving timer %d\n", tmr.Id)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
fmt.Println(a.getDoneTimerString(tmr))
|
||||||
|
} else {
|
||||||
|
fmt.Println("Refusing to archive running timer:", tmr.Id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// I guess we're archiving by timer id
|
||||||
if id, err = strconv.Atoi(v); err != nil {
|
if id, err = strconv.Atoi(v); err != nil {
|
||||||
fmt.Printf("Invalid id given: %s\n", v)
|
fmt.Printf("Invalid id given: %s\n", v)
|
||||||
return 1
|
return 1
|
||||||
@ -247,11 +283,16 @@ func (a *AppState) opArchiveTimer(args []string) int {
|
|||||||
fmt.Printf("Error getting timer %d\n", id)
|
fmt.Printf("Error getting timer %d\n", id)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
if timer.Finished {
|
||||||
if err = a.archiveTimer(id); err != nil {
|
if err = a.archiveTimer(id); err != nil {
|
||||||
fmt.Printf("Error archiving timer %d\n", id)
|
fmt.Printf("Error archiving timer %d\n", id)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
fmt.Println(a.getDoneTimerString(*timer))
|
fmt.Println(a.getDoneTimerString(*timer))
|
||||||
|
} else {
|
||||||
|
fmt.Println("Refusing to archive running timer:", timer.Id)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for _, v := range *a.TimerList {
|
for _, v := range *a.TimerList {
|
||||||
|
Loading…
Reference in New Issue
Block a user