@@ -5,52 +5,60 @@ import (
55 "github.com/spf13/cobra"
66)
77
8- func NewHelpTopic ( topic string ) * cobra. Command {
9- topicContent := make ( map [ string ] string )
10-
11- topicContent [ "environment" ] = heredoc .Doc (`
12- GITHUB_TOKEN: an authentication token for github.com API requests. Setting this avoids
13- being prompted to authenticate and takes precedence over previously stored credentials.
8+ var HelpTopics = map [ string ] map [ string ] string {
9+ "environment" : {
10+ "short" : "Environment variables that can be used with gh" ,
11+ "long" : heredoc .Doc (`
12+ GITHUB_TOKEN: an authentication token for github.com API requests. Setting this avoids
13+ being prompted to authenticate and takes precedence over previously stored credentials.
1414
15- GITHUB_ENTERPRISE_TOKEN: an authentication token for API requests to GitHub Enterprise.
15+ GITHUB_ENTERPRISE_TOKEN: an authentication token for API requests to GitHub Enterprise.
1616
17- GH_REPO: specify the GitHub repository in the "[HOST/]OWNER/REPO" format for commands
18- that otherwise operate on a local repository.
17+ GH_REPO: specify the GitHub repository in the "[HOST/]OWNER/REPO" format for commands
18+ that otherwise operate on a local repository.
1919
20- GH_HOST: specify the GitHub hostname for commands that would otherwise assume
21- the "github.com" host when not in a context of an existing repository.
20+ GH_HOST: specify the GitHub hostname for commands that would otherwise assume
21+ the "github.com" host when not in a context of an existing repository.
2222
23- GH_EDITOR, GIT_EDITOR, VISUAL, EDITOR (in order of precedence): the editor tool to use
24- for authoring text.
23+ GH_EDITOR, GIT_EDITOR, VISUAL, EDITOR (in order of precedence): the editor tool to use
24+ for authoring text.
2525
26- BROWSER: the web browser to use for opening links.
26+ BROWSER: the web browser to use for opening links.
2727
28- DEBUG: set to any value to enable verbose output to standard error. Include values "api"
29- or "oauth" to print detailed information about HTTP requests or authentication flow.
28+ DEBUG: set to any value to enable verbose output to standard error. Include values "api"
29+ or "oauth" to print detailed information about HTTP requests or authentication flow.
3030
31- GH_PAGER, PAGER (in order of precedence): a terminal paging program to send standard output to, e.g. "less".
31+ GH_PAGER, PAGER (in order of precedence): a terminal paging program to send standard output to, e.g. "less".
3232
33- GLAMOUR_STYLE: the style to use for rendering Markdown. See
34- https://github.com/charmbracelet/glamour#styles
33+ GLAMOUR_STYLE: the style to use for rendering Markdown. See
34+ https://github.com/charmbracelet/glamour#styles
3535
36- NO_COLOR: set to any value to avoid printing ANSI escape sequences for color output.
36+ NO_COLOR: set to any value to avoid printing ANSI escape sequences for color output.
3737
38- CLICOLOR: set to "0" to disable printing ANSI colors in output.
38+ CLICOLOR: set to "0" to disable printing ANSI colors in output.
3939
40- CLICOLOR_FORCE: set to a value other than "0" to keep ANSI colors in output
41- even when the output is piped.
40+ CLICOLOR_FORCE: set to a value other than "0" to keep ANSI colors in output
41+ even when the output is piped.
4242
43- GH_NO_UPDATE_NOTIFIER: set to any value to disable update notifications. By default, gh
44- checks for new releases once every 24 hours and displays an upgrade notice on standard
45- error if a newer version was found.
46- ` )
43+ GH_NO_UPDATE_NOTIFIER: set to any value to disable update notifications. By default, gh
44+ checks for new releases once every 24 hours and displays an upgrade notice on standard
45+ error if a newer version was found.
46+ ` ),
47+ },
48+ }
4749
50+ func NewHelpTopic (topic string ) * cobra.Command {
4851 cmd := & cobra.Command {
4952 Use : topic ,
50- Long : topicContent [topic ],
53+ Short : HelpTopics [topic ]["short" ],
54+ Long : HelpTopics [topic ]["long" ],
5155 Hidden : true ,
5256 Args : cobra .NoArgs ,
5357 Run : helpTopicHelpFunc ,
58+ Annotations : map [string ]string {
59+ "markdown:generate" : "true" ,
60+ "markdown:basename" : "gh_help_" + topic ,
61+ },
5462 }
5563
5664 cmd .SetHelpFunc (helpTopicHelpFunc )
0 commit comments