Implemented appendProjectIDToTask flag
This commit is contained in:
parent
2465fec28b
commit
0247fe0859
1 changed files with 86 additions and 79 deletions
13
z/listCmd.go
13
z/listCmd.go
|
@ -1,15 +1,17 @@
|
||||||
package z
|
package z
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"github.com/shopspring/decimal"
|
"github.com/shopspring/decimal"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var listTotalTime bool
|
var listTotalTime bool
|
||||||
var listOnlyProjectsAndTasks bool
|
var listOnlyProjectsAndTasks bool
|
||||||
|
var appendProjectIDToTask bool
|
||||||
|
|
||||||
var listCmd = &cobra.Command{
|
var listCmd = &cobra.Command{
|
||||||
Use: "list",
|
Use: "list",
|
||||||
|
@ -69,14 +71,18 @@ var listCmd = &cobra.Command{
|
||||||
fmt.Printf("%s %s\n", CharMore, project)
|
fmt.Printf("%s %s\n", CharMore, project)
|
||||||
|
|
||||||
for task, _ := range projectsAndTasks[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)
|
fmt.Printf("%*s└── %s\n", 1, " ", task)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
totalHours := decimal.NewFromInt(0);
|
totalHours := decimal.NewFromInt(0)
|
||||||
for _, entry := range filteredEntries {
|
for _, entry := range filteredEntries {
|
||||||
totalHours = totalHours.Add(entry.GetDuration())
|
totalHours = totalHours.Add(entry.GetDuration())
|
||||||
fmt.Printf("%s\n", entry.GetOutput(false))
|
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().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(&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(&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
|
var err error
|
||||||
database, err = InitDatabase()
|
database, err = InitDatabase()
|
||||||
|
|
Loading…
Reference in a new issue