MCPcopy Index your code
hub / github.com/git-bug/git-bug / NewRootCommand

Function NewRootCommand

commands/root.go:22–83  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20var GitExactTag string
21
22func NewRootCommand() *cobra.Command {
23 cmd := &cobra.Command{
24 Use: execenv.RootCommandName,
25 Short: "A bug tracker embedded in Git",
26 Long: `git-bug is a bug tracker embedded in git.
27
28git-bug use git objects to store the bug tracking separated from the files
29history. As bugs are regular git objects, they can be pushed and pulled from/to
30the same git remote you are already using to collaborate with other people.
31
32`,
33
34 PersistentPreRun: func(cmd *cobra.Command, args []string) {
35 root := cmd.Root()
36 root.Version = getVersion()
37 },
38
39 // For the root command, force the execution of the PreRun
40 // even if we just display the help. This is to make sure that we check
41 // the repository and give the user early feedback.
42 Run: func(cmd *cobra.Command, args []string) {
43 if err := cmd.Help(); err != nil {
44 os.Exit(1)
45 }
46 },
47
48 SilenceUsage: true,
49 DisableAutoGenTag: true,
50 }
51
52 const entityGroup = "entity"
53 const uiGroup = "ui"
54 const remoteGroup = "remote"
55
56 cmd.AddGroup(&cobra.Group{ID: entityGroup, Title: "Entities"})
57 cmd.AddGroup(&cobra.Group{ID: uiGroup, Title: "Interactive interfaces"})
58 cmd.AddGroup(&cobra.Group{ID: remoteGroup, Title: "Interaction with the outside world"})
59
60 addCmdWithGroup := func(child *cobra.Command, groupID string) {
61 cmd.AddCommand(child)
62 child.GroupID = groupID
63 }
64
65 env := execenv.NewEnv()
66
67 addCmdWithGroup(bugcmd.NewBugCommand(env), entityGroup)
68 addCmdWithGroup(usercmd.NewUserCommand(env), entityGroup)
69 addCmdWithGroup(newLabelCommand(env), entityGroup)
70
71 addCmdWithGroup(newTermUICommand(env), uiGroup)
72 addCmdWithGroup(newWebUICommand(env), uiGroup)
73
74 addCmdWithGroup(newPullCommand(env), remoteGroup)
75 addCmdWithGroup(newPushCommand(env), remoteGroup)
76 addCmdWithGroup(bridgecmd.NewBridgeCommand(env), remoteGroup)
77
78 cmd.AddCommand(newCommandsCommand(env))
79 cmd.AddCommand(newVersionCommand(env))

Callers 4

mainFunction · 0.92
mainFunction · 0.92
runCommandsFunction · 0.85
ExecuteFunction · 0.85

Calls 10

NewEnvFunction · 0.92
getVersionFunction · 0.85
newLabelCommandFunction · 0.85
newTermUICommandFunction · 0.85
newWebUICommandFunction · 0.85
newPullCommandFunction · 0.85
newPushCommandFunction · 0.85
newCommandsCommandFunction · 0.85
newVersionCommandFunction · 0.85
newWipeCommandFunction · 0.85

Tested by

no test coverage detected