diff --git a/command/root.go b/command/root.go index a2d8fed95..ebd5445d2 100644 --- a/command/root.go +++ b/command/root.go @@ -28,6 +28,7 @@ var Version = "DEV" var BuildDate = "" // YYYY-MM-DD var versionOutput = "" +var cobraDefaultHelpFunc func(*cobra.Command, []string) func init() { if Version == "DEV" { @@ -51,6 +52,7 @@ func init() { // TODO: // RootCmd.PersistentFlags().BoolP("verbose", "V", false, "enable verbose output") + cobraDefaultHelpFunc = RootCmd.HelpFunc() RootCmd.SetHelpFunc(rootHelpFunc) RootCmd.SetFlagErrorFunc(func(cmd *cobra.Command, err error) error { @@ -249,6 +251,11 @@ func determineBaseRepo(cmd *cobra.Command, ctx context.Context) (ghrepo.Interfac } func rootHelpFunc(command *cobra.Command, s []string) { + if command != RootCmd { + cobraDefaultHelpFunc(command, s) + return + } + type helpEntry struct { Title string Body string