MCPcopy Create free account
hub / github.com/caarlos0/tasktimer / newRootCmd

Function newRootCmd

internal/cmd/root.go:26–65  ·  view source on GitHub ↗
(version string, exit func(int))

Source from the content-addressed store, hash-verified

24}
25
26func newRootCmd(version string, exit func(int)) *rootCmd {
27 root := &rootCmd{
28 exit: exit,
29 }
30 cmd := &cobra.Command{
31 Use: "tt",
32 Short: "Task Timer (tt) is a dead simple TUI task timer",
33 Version: version,
34 SilenceUsage: true,
35 RunE: func(cmd *cobra.Command, args []string) error {
36 db, f, err := setup(root.project)
37 if err != nil {
38 return err
39 }
40 defer db.Close()
41 defer f.Close()
42
43 p := tea.NewProgram(ui.Init(db, root.project))
44 p.EnterAltScreen()
45 defer p.ExitAltScreen()
46 return p.Start()
47 },
48 }
49
50 cmd.PersistentFlags().StringVarP(&root.project, "project", "p", "default", "Project name")
51
52 cmd.AddCommand(
53 newRerportCmd().cmd,
54 newCompletionCmd().cmd,
55 newPathsCmd().cmd,
56 newToJSONCmd().cmd,
57 newFromJSONCmd().cmd,
58 newListCmd().cmd,
59 newEditCmd().cmd,
60 newManCmd().cmd,
61 )
62
63 root.cmd = cmd
64 return root
65}

Callers 1

ExecuteFunction · 0.85

Calls 10

InitFunction · 0.92
setupFunction · 0.85
newRerportCmdFunction · 0.85
newCompletionCmdFunction · 0.85
newPathsCmdFunction · 0.85
newToJSONCmdFunction · 0.85
newFromJSONCmdFunction · 0.85
newListCmdFunction · 0.85
newEditCmdFunction · 0.85
newManCmdFunction · 0.85

Tested by

no test coverage detected