Skip to content

Commit a7cef60

Browse files
Merge pull request cli#889 from cli/hacky-help
Fix the help docs on subcommands
2 parents c7f7bfc + 1f0db96 commit a7cef60

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

command/root.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var Version = "DEV"
2828
var BuildDate = "" // YYYY-MM-DD
2929

3030
var versionOutput = ""
31+
var cobraDefaultHelpFunc func(*cobra.Command, []string)
3132

3233
func init() {
3334
if Version == "DEV" {
@@ -51,6 +52,7 @@ func init() {
5152
// TODO:
5253
// RootCmd.PersistentFlags().BoolP("verbose", "V", false, "enable verbose output")
5354

55+
cobraDefaultHelpFunc = RootCmd.HelpFunc()
5456
RootCmd.SetHelpFunc(rootHelpFunc)
5557

5658
RootCmd.SetFlagErrorFunc(func(cmd *cobra.Command, err error) error {
@@ -249,6 +251,11 @@ func determineBaseRepo(cmd *cobra.Command, ctx context.Context) (ghrepo.Interfac
249251
}
250252

251253
func rootHelpFunc(command *cobra.Command, s []string) {
254+
if command != RootCmd {
255+
cobraDefaultHelpFunc(command, s)
256+
return
257+
}
258+
252259
type helpEntry struct {
253260
Title string
254261
Body string

0 commit comments

Comments
 (0)