Prepend new timers to front of list, not back
Also, add Remove operation
This commit is contained in:
parent
6b1cc0866f
commit
5174472bf0
@ -150,6 +150,13 @@ func (a *AppState) initialize() {
|
|||||||
},
|
},
|
||||||
a.opSwitchTimer,
|
a.opSwitchTimer,
|
||||||
)
|
)
|
||||||
|
a.addOperation("rm",
|
||||||
|
[]string{
|
||||||
|
"rm [id] - Removes the timer with the given id",
|
||||||
|
" WARNING: CANNOT BE UNDONE",
|
||||||
|
},
|
||||||
|
a.opRemoveTimer,
|
||||||
|
)
|
||||||
a.addOperation("archive",
|
a.addOperation("archive",
|
||||||
[]string{
|
[]string{
|
||||||
"archive [id] - Archive the timer with the given id",
|
"archive [id] - Archive the timer with the given id",
|
||||||
|
27
timer_ops.go
27
timer_ops.go
@ -267,6 +267,33 @@ func (a *AppState) opArchiveTimer(args []string) int {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *AppState) opRemoveTimer(args []string) int {
|
||||||
|
if len(args) == 0 {
|
||||||
|
fmt.Println("No timer id given")
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
id, err := strconv.Atoi(args[0])
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Invalid timer id given: " + args[0])
|
||||||
|
}
|
||||||
|
t, err := a.TimerList.GetTimer(id)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error getting timer with id: " + args[0])
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
if err = a.TimerList.RemoveTimerById(id); err != nil {
|
||||||
|
fmt.Println("Error Removing Timer: " + err.Error())
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
fmt.Println("Timer removed")
|
||||||
|
fmt.Println(TimerToString(t))
|
||||||
|
if err := a.WriteList(); err != nil {
|
||||||
|
fmt.Println(err.Error())
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
func (a *AppState) opModifyTimer(args []string) int {
|
func (a *AppState) opModifyTimer(args []string) int {
|
||||||
var timer *timertxt.Timer
|
var timer *timertxt.Timer
|
||||||
var contexts, projects []string
|
var contexts, projects []string
|
||||||
|
Loading…
Reference in New Issue
Block a user