worktime/internal/cli/commands/root.go
2025-11-07 13:40:22 +01:00

41 lines
1 KiB
Go

package commands
import (
"fmt"
"os"
cmd_group "git.zervo.org/zervo/worktime/internal/cli/commands/group"
cmd_version "git.zervo.org/zervo/worktime/internal/cli/commands/version"
"git.zervo.org/zervo/worktime/internal/util"
"github.com/spf13/cobra"
)
var (
verbose bool
rootCmd = &cobra.Command{
Use: "worktime",
Short: "WorkTime is a CLI project time management utility",
Long: `WorkTime is a CLI time management utility for keeping track of time spent on different projects.
Can associate git directories and user-provided summaries with sessions. Exports to CSVs or directly to PDFs.`,
}
)
// Execute will execute the root command of the application
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
func init() {
rootCmd.SetErrPrefix("ERROR:")
rootCmd.SetErr(util.NewErrorWriter())
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "V", false, "increase output verbosity")
rootCmd.AddCommand(cmd_version.Cmd)
rootCmd.AddCommand(cmd_group.Cmd)
}