Merge pull request #889 from cli/hacky-help

Fix the help docs on subcommands
This commit is contained in:
Corey Johnson 2020-05-11 09:39:53 -07:00 committed by GitHub
commit a7cef60aae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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