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 1/2] 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) From 621cd4153e5ccb8ba0ec95a43c22078655acd748 Mon Sep 17 00:00:00 2001 From: Matthew Runo <74583+inktomi@users.noreply.github.com> Date: Mon, 15 Aug 2022 15:25:39 -0700 Subject: [PATCH 2/2] Fixes #6024. Adding documentation for exit codes used by 'gh' --- pkg/cmd/root/help_topic.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/cmd/root/help_topic.go b/pkg/cmd/root/help_topic.go index c2c6ce0ac..231b102f3 100644 --- a/pkg/cmd/root/help_topic.go +++ b/pkg/cmd/root/help_topic.go @@ -138,6 +138,10 @@ var HelpTopics = map[string]map[string]string{ - If a command fails for any reason, the exit code will be 1 + - If a command is running but gets cancelled, the exit code will be 2 + + - If a command encounters an authentication issue, the exit code will be 4 + 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.