From 56ffde16fe359255ab907fe803c48d3243cd168a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=9E=E3=83=AA=E3=82=A6=E3=82=B9?= Date: Sat, 17 Oct 2020 13:17:01 +0100 Subject: [PATCH] Added notes to Entry and track command --- z/entry.go | 1 + z/project.go | 2 +- z/root.go | 1 + z/track.go | 5 +++++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/z/entry.go b/z/entry.go index a5f4f4b..0648e5a 100644 --- a/z/entry.go +++ b/z/entry.go @@ -14,6 +14,7 @@ type Entry struct { Finish time.Time `json:"finish,omitempty"` Project string `json:"project,omitempty"` Task string `json:"task,omitempty"` + Notes string `json:"notes,omitempty"` User string `json:"user,omitempty"` SHA1 string `json:"-"` diff --git a/z/project.go b/z/project.go index af27452..13ad288 100644 --- a/z/project.go +++ b/z/project.go @@ -3,6 +3,7 @@ package z import ( "os" "fmt" + // "time" "github.com/spf13/cobra" // "github.com/gookit/color" ) @@ -23,7 +24,6 @@ var projectCmd = &cobra.Command{ user := GetCurrentUser() projectName := args[0] - project, err := database.GetProject(user, projectName) if err != nil { fmt.Printf("%s %+v\n", CharError, err) diff --git a/z/root.go b/z/root.go index 1382cb2..b4f3fec 100644 --- a/z/root.go +++ b/z/root.go @@ -12,6 +12,7 @@ var begin string var finish string var project string var task string +var notes string var force bool diff --git a/z/track.go b/z/track.go index 3f30426..a9cf0e6 100644 --- a/z/track.go +++ b/z/track.go @@ -30,6 +30,10 @@ var trackCmd = &cobra.Command{ os.Exit(1) } + if notes != "" { + newEntry.Notes = notes + } + isRunning := newEntry.Finish.IsZero() _, err = database.AddEntry(user, newEntry, isRunning) @@ -49,6 +53,7 @@ func init() { trackCmd.Flags().StringVarP(&finish, "finish", "s", "", "Time the activity should finish at\n\nEither in the formats 16:00 / 4:00PM \nor relative to the current time, \ne.g. -0:15 (now minus 15 minutes), +1.50 (now plus 1:30h).\nMust be after --begin time.") trackCmd.Flags().StringVarP(&project, "project", "p", "", "Project to be assigned") trackCmd.Flags().StringVarP(&task, "task", "t", "", "Task to be assigned") + trackCmd.Flags().StringVarP(¬es, "notes", "n", "", "Activity notes") trackCmd.Flags().BoolVarP(&force, "force", "f", false, "Force begin tracking of a new task \neven though another one is still running \n(ONLY IF YOU KNOW WHAT YOU'RE DOING!)") var err error