Actually fix switch

This commit is contained in:
Brian Buller 2018-04-12 16:11:54 -05:00
parent dbd838e77f
commit acc6d135e5
2 changed files with 11 additions and 16 deletions

View File

@ -74,11 +74,11 @@ func InferTimerDetailString(t *gime.TimeEntry) string {
} }
func TimerDetailToString(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() { if t.GetEnd().IsZero() {
ret += " (" + padLeft(sinceToString(t.GetStart()), len("00h 00m 00s")) + ") " ret += "**:** (" + padLeft(sinceToString(t.GetStart()), len("00h 00m 00s")) + ") "
} else { } 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 { if t.GetTags().Length() > 0 {
ret += " [ " ret += " [ "

View File

@ -38,7 +38,7 @@ func cmdStartTimer(args []string) int {
return 1 return 1
} }
fmt.Println(" " + TimerToString(entry)) fmt.Println("Started:", TimerToString(entry))
return 0 return 0
} }
@ -61,27 +61,22 @@ func cmdContinueTimer(args []string) int {
// switchTimer performs a stop on any currently running timers // switchTimer performs a stop on any currently running timers
// and starts a new timer with the given arguments // and starts a new timer with the given arguments
func cmdSwitchTimer(args []string) int { func cmdSwitchTimer(args []string) int {
var foundId bool stopId := "@all"
stopIdIdx := -1
for i := range args { for i := range args {
// see if we have a timer id in the args // see if we have a timer id in the args
if args[i][0] == '@' { if args[i][0] == '@' {
foundId = true stopId = args[i]
stopIdIdx = i
} }
} }
stopArgs := make([]string, len(args)) if stopIdIdx >= 0 {
copy(stopArgs, args) args = append(args[:stopIdIdx], args[stopIdIdx+1:]...)
if !foundId {
// We didn't find one, so make sure we stop _all_ timers
stopArgs = append(stopArgs, "@all")
} }
fmt.Println(stopArgs) if cmdStopTimer([]string{stopId}) != 0 {
fmt.Println(args)
return 0
if cmdStopTimer(args) != 0 {
// Error while stopping timers // Error while stopping timers
return 1 return 1
} }
fmt.Println("Started Timer:")
return cmdStartTimer(args) return cmdStartTimer(args)
} }