Skip to content

Commit

Permalink
Improve help section layout (#2539)
Browse files Browse the repository at this point in the history
  • Loading branch information
sverdlov93 committed May 7, 2024
1 parent 3f830ed commit 4f1043c
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 36 deletions.
1 change: 0 additions & 1 deletion artifactory/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,6 @@ func GetCommands() []cli.Command {
Name: "go",
Hidden: true,
Flags: cliutils.GetCommandFlags(cliutils.Go),
Aliases: []string{"go"},
Usage: gocommand.GetDescription(),
HelpName: corecommon.CreateUsage("rt go", gocommand.GetDescription(), gocommand.Usage),
UsageText: gocommand.GetArguments(),
Expand Down
1 change: 0 additions & 1 deletion buildtools/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ func GetCommands() []cli.Command {
{
Name: "go",
Flags: cliutils.GetCommandFlags(cliutils.Go),
Aliases: []string{"go"},
Usage: gocommand.GetDescription(),
HelpName: corecommon.CreateUsage("go", gocommand.GetDescription(), gocommand.Usage),
UsageText: gocommand.GetArguments(),
Expand Down
10 changes: 5 additions & 5 deletions docs/artifactory/buildaddgit/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package buildaddgit
var Usage = []string{"rt bag [command options] <build name> <build number> [Path To .git]"}

func GetDescription() string {
return "Collects the Git revision and URL from the local .git directory and adds it to the build-info.\n" +
"It can also collect the list of tracked project issues (for example, issues stored in JIRA or other bug tracking systems) and add them to the build-info.\n" +
"The issues are collected by reading the git commit messages from the local git log.\n" +
"Each commit message is matched against a pre-configured regular expression, which retrieves the issue ID and issue summary.\n" +
"The information required for collecting the issues is retrieved from a yaml configuration file provided to the command."
return `Collects the Git revision and URL from the local .git directory and adds it to the build-info.
It can also collect the list of tracked project issues (for example, issues stored in JIRA or other bug tracking systems) and add them to the build-info.
The issues are collected by reading the git commit messages from the local git log.
Each commit message is matched against a pre-configured regular expression, which retrieves the issue ID and issue summary.
The information required for collecting the issues is retrieved from a yaml configuration file provided to the command.`
}

func GetArguments() string {
Expand Down
3 changes: 2 additions & 1 deletion docs/artifactory/transferconfig/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package transferconfig
var Usage = []string{"rt transfer-config [command options] <source-server-id> <target-server-id>"}

func GetDescription() string {
return "Copy full Artifactory configuration from source Artifactory server to target Artifactory server. Warning - This action will wipe all Artifactory content in this target server."
return `Copy full Artifactory configuration from source Artifactory server to target Artifactory server.
Warning - This action will wipe all Artifactory content in this target server.`
}

func GetArguments() string {
Expand Down
5 changes: 2 additions & 3 deletions docs/general/token/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package token
var Usage = []string{"atc", "atc <username>"}

func GetDescription() string {
return `Creates an access token.
By default, an user-scoped token will be created.
Administrator may provide the scope explicitly with '--scope', or implicitly with '--groups', '--grant-admin'.`
return `Creates an access token. By default, an user-scoped token will be created.
Administrator may provide the scope explicitly with '--scope', or implicitly with '--groups', '--grant-admin'.`
}

func GetArguments() string {
Expand Down
50 changes: 25 additions & 25 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ const subcommandHelpTemplate = `NAME:
{{.HelpName}} - {{.Usage}}
USAGE:
{{if .Usage}}{{.Usage}}{{ "\n\t" }}{{end}}{{.HelpName}} command{{if .VisibleFlags}} [command options]{{end}} [arguments...]
{{.HelpName}} command{{if .VisibleFlags}} [command options]{{end}} [arguments...]
COMMANDS:
{{range .Commands}}{{join .Names ", "}}{{ "\t" }}{{.Usage}}
{{range .VisibleCommands}}{{join .Names ", "}}{{ "\t" }}{{.Usage}}
{{end}}{{if .VisibleFlags}}{{if .ArgsUsage}}
Arguments:
{{.ArgsUsage}}{{ "\n" }}{{end}}
Expand All @@ -94,7 +94,7 @@ func execMain() error {

app := cli.NewApp()
app.Name = jfrogAppName
app.Usage = "See https://github.com/jfrog/jfrog-cli for usage instructions."
app.Usage = "See https://docs.jfrog-applications.jfrog.io/jfrog-applications/jfrog-cli for full documentation."
app.Version = cliutils.GetVersion()
args := os.Args
cliutils.SetCliExecutableName(args[0])
Expand All @@ -110,7 +110,7 @@ func execMain() error {
cli.AppHelpTemplate = getAppHelpTemplate()
cli.SubcommandHelpTemplate = subcommandHelpTemplate
app.CommandNotFound = func(c *cli.Context, command string) {
_, err := fmt.Fprintf(c.App.Writer, "'"+c.App.Name+" "+command+"' is not a jf command. See --help\n")
_, err = fmt.Fprintf(c.App.Writer, "'"+c.App.Name+" "+command+"' is not a jf command. See --help\n")
if err != nil {
clientlog.Debug(err)
os.Exit(1)
Expand Down Expand Up @@ -209,32 +209,33 @@ func searchSimilarCmds(cmds []cli.Command, toCompare string) (bestSimilarity []s
}

const otherCategory = "Other"
const commandNamespacesCategory = "Command Namespaces"

func getCommands() ([]cli.Command, error) {
cliNameSpaces := []cli.Command{
{
Name: cliutils.CmdArtifactory,
Usage: "JFrog Artifactory commands.",
Usage: "Artifactory commands.",
Subcommands: artifactory.GetCommands(),
Category: otherCategory,
Category: commandNamespacesCategory,
},
{
Name: cliutils.CmdMissionControl,
Usage: "JFrog Mission Control commands.",
Usage: "Mission Control commands.",
Subcommands: missioncontrol.GetCommands(),
Category: otherCategory,
Category: commandNamespacesCategory,
},
{
Name: cliutils.CmdDistribution,
Usage: "JFrog Distribution V1 commands.",
Usage: "Distribution V1 commands.",
Subcommands: distribution.GetCommands(),
Category: otherCategory,
Category: commandNamespacesCategory,
},
{
Name: cliutils.CmdPipelines,
Usage: "JFrog Pipelines commands.",
Usage: "Pipelines commands.",
Subcommands: pipelines.GetCommands(),
Category: otherCategory,
Category: commandNamespacesCategory,
},
{
Name: cliutils.CmdCompletion,
Expand All @@ -246,14 +247,14 @@ func getCommands() ([]cli.Command, error) {
Name: cliutils.CmdPlugin,
Usage: "Plugins handling commands.",
Subcommands: plugins.GetCommands(),
Category: otherCategory,
Category: commandNamespacesCategory,
},
{
Name: cliutils.CmdConfig,
Aliases: []string{"c"},
Usage: "Config server configurations commands.",
Usage: "Server configurations commands.",
Subcommands: config.GetCommands(),
Category: otherCategory,
Category: commandNamespacesCategory,
},
{
Name: cliutils.CmdProject,
Expand All @@ -275,18 +276,16 @@ func getCommands() ([]cli.Command, error) {
},
},
{
Name: "setup",
HideHelp: true,
Hidden: true,
Flags: cliutils.GetCommandFlags(cliutils.Setup),
Action: SetupCmd,
Name: "setup",
Hidden: true,
Flags: cliutils.GetCommandFlags(cliutils.Setup),
Action: SetupCmd,
},
{
Name: "intro",
HideHelp: true,
Hidden: true,
Flags: cliutils.GetCommandFlags(cliutils.Intro),
Action: IntroCmd,
Name: "intro",
Hidden: true,
Flags: cliutils.GetCommandFlags(cliutils.Intro),
Action: IntroCmd,
},
{
Name: cliutils.CmdOptions,
Expand Down Expand Up @@ -322,6 +321,7 @@ func getCommands() ([]cli.Command, error) {
UsageText: tokenDocs.GetArguments(),
ArgsUsage: common.CreateEnvVars(),
BashComplete: corecommon.CreateBashCompletionFunc(),
Category: otherCategory,
Action: token.AccessTokenCreateCmd,
},
}
Expand Down

0 comments on commit 4f1043c

Please sign in to comment.