Merge pull request #6081 from inktomi/exit-codes

Document exit codes used by gh
This commit is contained in:
Nate Smith 2022-08-16 12:44:01 -05:00 committed by GitHub
commit 493987a32c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View file

@ -129,6 +129,24 @@ 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
- 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.
`),
},
}
func NewHelpTopic(ios *iostreams.IOStreams, topic string) *cobra.Command {

View file

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