Extended finish command with notes and Git log import
This commit is contained in:
parent
b50277d9ce
commit
5dd03146b2
1 changed files with 27 additions and 0 deletions
27
z/finish.go
27
z/finish.go
|
@ -55,6 +55,32 @@ var finishCmd = &cobra.Command{
|
||||||
runningEntry.Task = tmpEntry.Task
|
runningEntry.Task = tmpEntry.Task
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if notes != "" {
|
||||||
|
runningEntry.Notes = fmt.Sprintf("%s\n%s", runningEntry.Notes, notes)
|
||||||
|
}
|
||||||
|
|
||||||
|
if runningEntry.Task != "" {
|
||||||
|
task, err := database.GetTask(user, runningEntry.Task)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("%s %+v\n", CharError, err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
if task.GitRepository != "" && task.GitRepository != "-" {
|
||||||
|
stdout, stderr, err := GetGitLog(task.GitRepository, runningEntry.Begin, runningEntry.Finish)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("%s %+v\n", CharError, err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
if stderr == "" {
|
||||||
|
runningEntry.Notes = fmt.Sprintf("%s\n%s", runningEntry.Notes, stdout)
|
||||||
|
} else {
|
||||||
|
fmt.Printf("%s notes were not imported: %+v\n", CharError, stderr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_, err = database.FinishEntry(user, runningEntry)
|
_, err = database.FinishEntry(user, runningEntry)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("%s %+v\n", CharError, err)
|
fmt.Printf("%s %+v\n", CharError, err)
|
||||||
|
@ -71,6 +97,7 @@ func init() {
|
||||||
finishCmd.Flags().StringVarP(&begin, "begin", "b", "", "Time the activity should begin 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).")
|
finishCmd.Flags().StringVarP(&begin, "begin", "b", "", "Time the activity should begin 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).")
|
||||||
finishCmd.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.")
|
finishCmd.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.")
|
||||||
finishCmd.Flags().StringVarP(&project, "project", "p", "", "Project to be assigned")
|
finishCmd.Flags().StringVarP(&project, "project", "p", "", "Project to be assigned")
|
||||||
|
finishCmd.Flags().StringVarP(¬es, "notes", "n", "", "Activity notes")
|
||||||
finishCmd.Flags().StringVarP(&task, "task", "t", "", "Task to be assigned")
|
finishCmd.Flags().StringVarP(&task, "task", "t", "", "Task to be assigned")
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
Loading…
Reference in a new issue