()
| 20 | var GitExactTag string |
| 21 | |
| 22 | func 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 | |
| 28 | git-bug use git objects to store the bug tracking separated from the files |
| 29 | history. As bugs are regular git objects, they can be pushed and pulled from/to |
| 30 | the 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)) |
no test coverage detected