Implemented appendProjectIDToTask flag

This commit is contained in:
マリウス 2021-07-05 19:43:31 -05:00
parent 2465fec28b
commit 0247fe0859
No known key found for this signature in database
GPG key ID: 272ED814BF63261F

View file

@ -1,15 +1,17 @@
package z
import (
"os"
"fmt"
"os"
"time"
"github.com/spf13/cobra"
"github.com/shopspring/decimal"
"github.com/spf13/cobra"
)
var listTotalTime bool
var listOnlyProjectsAndTasks bool
var appendProjectIDToTask bool
var listCmd = &cobra.Command{
Use: "list",
@ -69,14 +71,18 @@ var listCmd = &cobra.Command{
fmt.Printf("%s %s\n", CharMore, project)
for task, _ := range projectsAndTasks[project] {
if appendProjectIDToTask == true {
fmt.Printf("%*s└── %s [%s]\n", 1, " ", task, project)
} else {
fmt.Printf("%*s└── %s\n", 1, " ", task)
}
}
}
return
}
totalHours := decimal.NewFromInt(0);
totalHours := decimal.NewFromInt(0)
for _, entry := range filteredEntries {
totalHours = totalHours.Add(entry.GetDuration())
fmt.Printf("%s\n", entry.GetOutput(false))
@ -97,6 +103,7 @@ func init() {
listCmd.Flags().StringVarP(&task, "task", "t", "", "Task to be listed")
listCmd.Flags().BoolVar(&listTotalTime, "total", false, "Show total time of hours for listed activities")
listCmd.Flags().BoolVar(&listOnlyProjectsAndTasks, "only-projects-and-tasks", false, "Only list projects and their tasks, no entries")
listCmd.Flags().BoolVar(&appendProjectIDToTask, "append-project-id-to-task", false, "Append project ID to tasks in the list")
var err error
database, err = InitDatabase()