aboutsummaryrefslogtreecommitdiffstats
path: root/commands/root.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2022-11-22 14:53:15 +0100
committerGitHub <noreply@github.com>2022-11-22 14:53:15 +0100
commit70bd7377b6362127794f3a6198dd2c63863025fc (patch)
treee159372673104ade1f15ddc1a84aa9da93e93552 /commands/root.go
parenta3fa445a9c76631c4cd16f93e1c1c68a954adef7 (diff)
parentacc9a6f3a6df2961c3ae44352216d915cb9b5315 (diff)
downloadgit-bug-70bd7377b6362127794f3a6198dd2c63863025fc.tar.gz
Merge pull request #870 from MichaelMure/cli-reorg
commands: reorg into different packages
Diffstat (limited to 'commands/root.go')
-rw-r--r--commands/root.go54
1 files changed, 32 insertions, 22 deletions
diff --git a/commands/root.go b/commands/root.go
index e012bd83..b28b77b8 100644
--- a/commands/root.go
+++ b/commands/root.go
@@ -6,9 +6,13 @@ import (
"os"
"github.com/spf13/cobra"
-)
-const rootCommandName = "git-bug"
+ "github.com/MichaelMure/git-bug/commands/bridge"
+ usercmd "github.com/MichaelMure/git-bug/commands/user"
+
+ "github.com/MichaelMure/git-bug/commands/bug"
+ "github.com/MichaelMure/git-bug/commands/execenv"
+)
// These variables are initialized externally during the build. See the Makefile.
var GitCommit string
@@ -17,8 +21,8 @@ var GitExactTag string
func NewRootCommand() *cobra.Command {
cmd := &cobra.Command{
- Use: rootCommandName,
- Short: "A bug tracker embedded in Git.",
+ Use: execenv.RootCommandName,
+ Short: "A bug tracker embedded in Git",
Long: `git-bug is a bug tracker embedded in git.
git-bug use git objects to store the bug tracking separated from the files
@@ -52,26 +56,32 @@ the same git remote you are already using to collaborate with other people.
DisableAutoGenTag: true,
}
- cmd.AddCommand(newAddCommand())
- cmd.AddCommand(newBridgeCommand())
+ const entityGroup = "entity"
+ const uiGroup = "ui"
+ const remoteGroup = "remote"
+
+ cmd.AddGroup(&cobra.Group{ID: entityGroup, Title: "Entities"})
+ cmd.AddGroup(&cobra.Group{ID: uiGroup, Title: "User interfaces"})
+ cmd.AddGroup(&cobra.Group{ID: remoteGroup, Title: "Interaction with the outside world"})
+
+ addCmdWithGroup := func(child *cobra.Command, groupID string) {
+ cmd.AddCommand(child)
+ child.GroupID = groupID
+ }
+
+ addCmdWithGroup(bugcmd.NewBugCommand(), entityGroup)
+ addCmdWithGroup(usercmd.NewUserCommand(), entityGroup)
+ addCmdWithGroup(newLabelCommand(), entityGroup)
+
+ addCmdWithGroup(newTermUICommand(), uiGroup)
+ addCmdWithGroup(newWebUICommand(), uiGroup)
+
+ addCmdWithGroup(newPullCommand(), remoteGroup)
+ addCmdWithGroup(newPushCommand(), remoteGroup)
+ addCmdWithGroup(bridgecmd.NewBridgeCommand(), remoteGroup)
+
cmd.AddCommand(newCommandsCommand())
- cmd.AddCommand(newCommentCommand())
- cmd.AddCommand(newDeselectCommand())
- cmd.AddCommand(newLabelCommand())
- cmd.AddCommand(newLsCommand())
- cmd.AddCommand(newLsIdCommand())
- cmd.AddCommand(newLsLabelCommand())
- cmd.AddCommand(newPullCommand())
- cmd.AddCommand(newPushCommand())
- cmd.AddCommand(newRmCommand())
- cmd.AddCommand(newSelectCommand())
- cmd.AddCommand(newShowCommand())
- cmd.AddCommand(newStatusCommand())
- cmd.AddCommand(newTermUICommand())
- cmd.AddCommand(newTitleCommand())
- cmd.AddCommand(newUserCommand())
cmd.AddCommand(newVersionCommand())
- cmd.AddCommand(newWebUICommand())
return cmd
}