@@ -13,9 +13,25 @@ func RootCmd() *cobra.Command {
1313 cfg := config .New ()
1414
1515 root := & cobra.Command {
16- Use : "stack <command>" ,
17- Short : "Manage stacked branches and pull requests" ,
18- Long : "Create, navigate, and manage stacks of branches and pull requests." ,
16+ Use : "stack <command>" ,
17+ Short : "Manage stacked branches and pull requests" ,
18+ Long : `Stacked PRs let you break a large change into a chain of pull requests
19+ that build on each other. Use ` + "`gh stack`" + ` to create and manage your stack
20+ locally, then push to GitHub to create your stack of PRs.` ,
21+ Example : ` # Start a new stack targeting your default branch
22+ $ gh stack init
23+
24+ # Or turn an existing set of branches into a stack
25+ $ gh stack init --adopt branch1 branch2 branch3
26+
27+ # Make changes and commit, then add a branch to the stack
28+ $ gh stack add branch4
29+
30+ # Push all branches and create/update PRs on GitHub
31+ $ gh stack submit
32+
33+ # Keep your local in sync with remote
34+ $ gh stack sync` ,
1935 Version : Version ,
2036 SilenceUsage : true ,
2137 SilenceErrors : true ,
@@ -26,36 +42,104 @@ func RootCmd() *cobra.Command {
2642 root .SetOut (cfg .Out )
2743 root .SetErr (cfg .Err )
2844
29- // Local operations
30- root .AddCommand (InitCmd (cfg ))
31- root .AddCommand (AddCmd (cfg ))
45+ root .AddGroup (
46+ & cobra.Group {ID : "stack" , Title : "Stack management:" },
47+ & cobra.Group {ID : "remote" , Title : "Remote operations:" },
48+ & cobra.Group {ID : "nav" , Title : "Navigation:" },
49+ & cobra.Group {ID : "utils" , Title : "Utilities:" },
50+ )
51+
52+ defaultHelp := root .HelpFunc ()
53+ root .SetHelpFunc (func (cmd * cobra.Command , args []string ) {
54+ defaultHelp (cmd , args )
55+ if cmd .Name () == "stack" {
56+ out := cmd .OutOrStderr ()
57+ fmt .Fprintln (out )
58+ fmt .Fprintln (out , "Learn more:" )
59+ fmt .Fprintln (out , " Documentation: https://gh.io/stacks" )
60+ fmt .Fprintln (out , " Feedback: https://gh.io/stacks-feedback" )
61+ }
62+ })
3263
33- // Remote operations
34- root .AddCommand (CheckoutCmd (cfg ))
35- root .AddCommand (PushCmd (cfg ))
36- root .AddCommand (SubmitCmd (cfg ))
37- root .AddCommand (SyncCmd (cfg ))
38- root .AddCommand (UnstackCmd (cfg ))
39- root .AddCommand (MergeCmd (cfg ))
40- root .AddCommand (LinkCmd (cfg ))
64+ // Stack management commands
65+ initCmd := InitCmd (cfg )
66+ initCmd .GroupID = "stack"
67+ root .AddCommand (initCmd )
4168
42- // Helper commands
43- root .AddCommand (ViewCmd (cfg ))
44- root .AddCommand (RebaseCmd (cfg ))
45- root .AddCommand (ModifyCmd (cfg ))
69+ addCmd := AddCmd (cfg )
70+ addCmd .GroupID = "stack"
71+ root .AddCommand (addCmd )
4672
47- // Navigation commands
48- root .AddCommand (UpCmd (cfg ))
49- root .AddCommand (DownCmd (cfg ))
50- root .AddCommand (TopCmd (cfg ))
51- root .AddCommand (BottomCmd (cfg ))
52- root .AddCommand (SwitchCmd (cfg ))
73+ viewCmd := ViewCmd (cfg )
74+ viewCmd .GroupID = "stack"
75+ root .AddCommand (viewCmd )
76+
77+ checkoutCmd := CheckoutCmd (cfg )
78+ checkoutCmd .GroupID = "stack"
79+ root .AddCommand (checkoutCmd )
80+
81+ modifyCmd := ModifyCmd (cfg )
82+ modifyCmd .GroupID = "stack"
83+ root .AddCommand (modifyCmd )
5384
54- // Alias
55- root .AddCommand (AliasCmd (cfg ))
85+ unstackCmd := UnstackCmd (cfg )
86+ unstackCmd .GroupID = "stack"
87+ root .AddCommand (unstackCmd )
5688
57- // Feedback
58- root .AddCommand (FeedbackCmd (cfg ))
89+ // Remote operations commands
90+ submitCmd := SubmitCmd (cfg )
91+ submitCmd .GroupID = "remote"
92+ root .AddCommand (submitCmd )
93+
94+ syncCmd := SyncCmd (cfg )
95+ syncCmd .GroupID = "remote"
96+ root .AddCommand (syncCmd )
97+
98+ rebaseCmd := RebaseCmd (cfg )
99+ rebaseCmd .GroupID = "remote"
100+ root .AddCommand (rebaseCmd )
101+
102+ pushCmd := PushCmd (cfg )
103+ pushCmd .GroupID = "remote"
104+ root .AddCommand (pushCmd )
105+
106+ linkCmd := LinkCmd (cfg )
107+ linkCmd .GroupID = "remote"
108+ root .AddCommand (linkCmd )
109+
110+ mergeCmd := MergeCmd (cfg )
111+ mergeCmd .GroupID = "remote"
112+ root .AddCommand (mergeCmd )
113+
114+ // Navigation commands
115+ switchCmd := SwitchCmd (cfg )
116+ switchCmd .GroupID = "nav"
117+ root .AddCommand (switchCmd )
118+
119+ upCmd := UpCmd (cfg )
120+ upCmd .GroupID = "nav"
121+ root .AddCommand (upCmd )
122+
123+ downCmd := DownCmd (cfg )
124+ downCmd .GroupID = "nav"
125+ root .AddCommand (downCmd )
126+
127+ topCmd := TopCmd (cfg )
128+ topCmd .GroupID = "nav"
129+ root .AddCommand (topCmd )
130+
131+ bottomCmd := BottomCmd (cfg )
132+ bottomCmd .GroupID = "nav"
133+ root .AddCommand (bottomCmd )
134+
135+ // Utility commands
136+ aliasCmd := AliasCmd (cfg )
137+ aliasCmd .GroupID = "utils"
138+ root .AddCommand (aliasCmd )
139+
140+ feedbackCmd := FeedbackCmd (cfg )
141+ feedbackCmd .GroupID = "utils"
142+ root .AddCommand (feedbackCmd )
59143
60144 return root
61145}
0 commit comments