Extended track command
This commit is contained in:
parent
30d61dc7d1
commit
1fbb947536
1 changed files with 15 additions and 9 deletions
24
z/track.go
24
z/track.go
|
@ -1,8 +1,11 @@
|
||||||
package z
|
package z
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"log"
|
"log"
|
||||||
|
"fmt"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
"github.com/gookit/color"
|
||||||
)
|
)
|
||||||
|
|
||||||
var trackCmd = &cobra.Command{
|
var trackCmd = &cobra.Command{
|
||||||
|
@ -18,7 +21,8 @@ var trackCmd = &cobra.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
if runningEntryId != "" {
|
if runningEntryId != "" {
|
||||||
log.Fatal("A task is already running. Please finish that before beginning to track a new task!")
|
fmt.Printf("▷ a task is already running\n")
|
||||||
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
|
|
||||||
newEntry, err := NewEntry("", begin, finish, project, task, user)
|
newEntry, err := NewEntry("", begin, finish, project, task, user)
|
||||||
|
@ -26,18 +30,20 @@ var trackCmd = &cobra.Command{
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
entryId, err := database.AddEntry(user, newEntry, true)
|
_, err = database.AddEntry(user, newEntry, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// entries, err := database.ListEntries()
|
if newEntry.Task != "" && newEntry.Project != "" {
|
||||||
// if err != nil {
|
fmt.Printf("▷ began tracking %s on %s\n", color.FgLightWhite.Render(newEntry.Task), color.FgLightWhite.Render(newEntry.Project))
|
||||||
// log.Fatal(err)
|
} else if newEntry.Task != "" && newEntry.Project == "" {
|
||||||
// }
|
fmt.Printf("▷ began tracking %s\n", color.FgLightWhite.Render(newEntry.Task))
|
||||||
// fmt.Printf("%+v", entries)
|
} else if newEntry.Task == "" && newEntry.Project != "" {
|
||||||
|
fmt.Printf("▷ began tracking task on %s\n", color.FgLightWhite.Render(newEntry.Project))
|
||||||
log.Printf("Added new entry with ID %s!\n", entryId)
|
} else {
|
||||||
|
fmt.Printf("▷ began tracking task\n")
|
||||||
|
}
|
||||||
return
|
return
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue