Actually fix switch
This commit is contained in:
parent
dbd838e77f
commit
acc6d135e5
@ -74,11 +74,11 @@ func InferTimerDetailString(t *gime.TimeEntry) string {
|
||||
}
|
||||
|
||||
func TimerDetailToString(t *gime.TimeEntry) string {
|
||||
ret := t.GetStart().Format("15:04")
|
||||
ret := t.GetStart().Format("15:04") + " - "
|
||||
if t.GetEnd().IsZero() {
|
||||
ret += " (" + padLeft(sinceToString(t.GetStart()), len("00h 00m 00s")) + ") "
|
||||
ret += "**:** (" + padLeft(sinceToString(t.GetStart()), len("00h 00m 00s")) + ") "
|
||||
} else {
|
||||
ret += " (" + padLeft(diffToString(t.GetStart(), t.GetEnd()), len("00h 00m 00s")) + ") "
|
||||
ret += t.GetEnd().Format("15:04") + " (" + padLeft(diffToString(t.GetStart(), t.GetEnd()), len("00h 00m 00s")) + ") "
|
||||
}
|
||||
if t.GetTags().Length() > 0 {
|
||||
ret += " [ "
|
||||
|
@ -38,7 +38,7 @@ func cmdStartTimer(args []string) int {
|
||||
return 1
|
||||
}
|
||||
|
||||
fmt.Println(" " + TimerToString(entry))
|
||||
fmt.Println("Started:", TimerToString(entry))
|
||||
return 0
|
||||
}
|
||||
|
||||
@ -61,27 +61,22 @@ func cmdContinueTimer(args []string) int {
|
||||
// switchTimer performs a stop on any currently running timers
|
||||
// and starts a new timer with the given arguments
|
||||
func cmdSwitchTimer(args []string) int {
|
||||
var foundId bool
|
||||
stopId := "@all"
|
||||
stopIdIdx := -1
|
||||
for i := range args {
|
||||
// see if we have a timer id in the args
|
||||
if args[i][0] == '@' {
|
||||
foundId = true
|
||||
stopId = args[i]
|
||||
stopIdIdx = i
|
||||
}
|
||||
}
|
||||
stopArgs := make([]string, len(args))
|
||||
copy(stopArgs, args)
|
||||
if !foundId {
|
||||
// We didn't find one, so make sure we stop _all_ timers
|
||||
stopArgs = append(stopArgs, "@all")
|
||||
if stopIdIdx >= 0 {
|
||||
args = append(args[:stopIdIdx], args[stopIdIdx+1:]...)
|
||||
}
|
||||
fmt.Println(stopArgs)
|
||||
fmt.Println(args)
|
||||
return 0
|
||||
if cmdStopTimer(args) != 0 {
|
||||
if cmdStopTimer([]string{stopId}) != 0 {
|
||||
// Error while stopping timers
|
||||
return 1
|
||||
}
|
||||
fmt.Println("Started Timer:")
|
||||
return cmdStartTimer(args)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user