Skip to content

Commit 9e4af47

Browse files
committed
Add command line docs for supported environment variables
1 parent 89adc83 commit 9e4af47

3 files changed

Lines changed: 30 additions & 3 deletions

File tree

command/help.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ func rootHelpFunc(command *cobra.Command, args []string) {
131131
if command.Example != "" {
132132
helpEntries = append(helpEntries, helpEntry{"EXAMPLES", command.Example})
133133
}
134+
if _, ok := command.Annotations["help:environment"]; ok {
135+
helpEntries = append(helpEntries, helpEntry{"ENVIRONMENT VARIABLES", command.Annotations["help:environment"]})
136+
}
134137
helpEntries = append(helpEntries, helpEntry{"LEARN MORE", `
135138
Use "gh <command> <subcommand> --help" for more information about a command.
136139
Read the manual at https://cli.github.com/manual`})

command/root.go

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,28 @@ var RootCmd = &cobra.Command{
111111
$ gh pr checkout 321
112112
`),
113113
Annotations: map[string]string{
114-
"help:feedback": `
115-
Fill out our feedback form https://forms.gle/umxd3h31c7aMQFKG7
116-
Open an issue using “gh issue create -R cli/cli”`},
114+
"help:feedback": heredoc.Doc(`
115+
Fill out our feedback form https://forms.gle/umxd3h31c7aMQFKG7
116+
Open an issue using “gh issue create -R cli/cli”
117+
`),
118+
"help:environment": heredoc.Doc(`
119+
GITHUB_TOKEN: an authentication token for API requests. Setting this avoids being
120+
prompted to authenticate and overrides any previously stored credentials.
121+
122+
GH_REPO: specify the GitHub repository in "OWNER/REPO" format for commands that
123+
otherwise operate on a local repository.
124+
125+
GH_EDITOR, GIT_EDITOR, VISUAL, EDITOR (in order of precedence): the editor tool to use
126+
for authoring text.
127+
128+
BROWSER: the web browser to use for opening links.
129+
130+
DEBUG: set to any value to enable verbose output to standard error. Include values "api"
131+
or "oauth" to print detailed information about HTTP requests or authentication flow.
132+
133+
NO_COLOR: avoid printing ANSI escape sequences for color output.
134+
`),
135+
},
117136
}
118137

119138
var versionCmd = &cobra.Command{

pkg/cmd/api/api.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ original query accepts an '$endCursor: String' variable and that it fetches the
109109
}
110110
'
111111
`),
112+
Annotations: map[string]string{
113+
"help:environment": heredoc.Doc(`
114+
GITHUB_TOKEN: an authentication token for API requests.
115+
`),
116+
},
112117
Args: cobra.ExactArgs(1),
113118
RunE: func(c *cobra.Command, args []string) error {
114119
opts.RequestPath = args[0]

0 commit comments

Comments
 (0)