Skip to content

Commit

Permalink
Merge pull request cli#889 from cli/hacky-help
Browse files Browse the repository at this point in the history
Fix the help docs on subcommands
  • Loading branch information
probablycorey authored May 11, 2020
2 parents c7f7bfc + 1f0db96 commit a7cef60
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions command/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a7cef60

Please sign in to comment.