From 9b16d1ecdd30fac7601407da6b6fdd1c856c98fb Mon Sep 17 00:00:00 2001 From: Matthew Runo <74583+inktomi@users.noreply.github.com> Date: Mon, 15 Aug 2022 15:20:19 -0700 Subject: [PATCH] Fixes #6024. Adding documentation for exit codes used by 'gh' --- pkg/cmd/root/help_topic.go | 14 ++++++++++++++ pkg/cmd/root/root.go | 1 + 2 files changed, 15 insertions(+) diff --git a/pkg/cmd/root/help_topic.go b/pkg/cmd/root/help_topic.go index 05798894b..c2c6ce0ac 100644 --- a/pkg/cmd/root/help_topic.go +++ b/pkg/cmd/root/help_topic.go @@ -129,6 +129,20 @@ var HelpTopics = map[string]map[string]string{ ' `), }, + "exit-codes": { + "short": "Exit codes used by gh", + "long": heredoc.Doc(` + gh follows normal conventions regarding exit codes. + + - If a command completes successfully, the exit code will be 0 + + - If a command fails for any reason, the exit code will be 1 + + NOTE: It is possible that a particular command may have more exit codes, so it is a good + practice to check documentation for the command if you are relying on exit codes to + control some behavior. + `), + }, } func NewHelpTopic(ios *iostreams.IOStreams, topic string) *cobra.Command { diff --git a/pkg/cmd/root/root.go b/pkg/cmd/root/root.go index 73db4377c..68f60eaa2 100644 --- a/pkg/cmd/root/root.go +++ b/pkg/cmd/root/root.go @@ -111,6 +111,7 @@ func NewCmdRoot(f *cmdutil.Factory, version, buildDate string) *cobra.Command { cmd.AddCommand(NewHelpTopic(f.IOStreams, "environment")) cmd.AddCommand(NewHelpTopic(f.IOStreams, "formatting")) cmd.AddCommand(NewHelpTopic(f.IOStreams, "mintty")) + cmd.AddCommand(NewHelpTopic(f.IOStreams, "exit-codes")) referenceCmd := NewHelpTopic(f.IOStreams, "reference") referenceCmd.SetHelpFunc(referenceHelpFn(f.IOStreams)) cmd.AddCommand(referenceCmd)