Skip to content

Commit c7ede29

Browse files
committed
Refactor help topics to include short message
1 parent cee26cf commit c7ede29

File tree

1 file changed

+32
-28
lines changed

1 file changed

+32
-28
lines changed

pkg/cmd/root/help_topic.go

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,49 +5,53 @@ 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": "Environmental 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,

0 commit comments

Comments
 (0)