Skip to content

Commit

Permalink
docs: adjust flags to options in cobra help and usage template (#1188)
Browse files Browse the repository at this point in the history
<!-- markdownlint-disable MD041 -->
#### What this PR does / why we need it
Renames the `Flags` section in `--help` to `Options`. The `Synopsis`
currently shows `ocm [<options>] ...`, with <options> referring to the
command line options listed under `Flags`. This might confuse users (or
at least concern if something does not work).

**Before:**
```
> ocm get component --help
ocm get componentversions — Get Component Version

Synopsis:
  ocm get componentversions [<options>] {<component-reference>}

Aliases:
  componentversions, componentversion, cv, components, component, comps, comp, c

Flags:
  -c, --constraints constraints   version constraint
  -h, --help                      help for componentversions
      --latest                    restrict component versions to latest
      --lookup stringArray        repository name or spec for closure lookup fallback
  -o, --output string             output mode (JSON, json, tree, wide, yaml)
  -r, --recursive                 follow component reference nesting
      --repo string               repository name or spec
  -S, --scheme string             schema version
  -s, --sort stringArray          sort fields
```

**Now:**
```
> ocm get component --help
ocm get componentversions — Get Component Version

Synopsis:
  ocm get componentversions [<options>] {<component-reference>}

Aliases:
  componentversions, componentversion, cv, components, component, comps, comp, c

Options:
  -c, --constraints constraints   version constraint
  -h, --help                      help for componentversions
      --latest                    restrict component versions to latest
      --lookup stringArray        repository name or spec for closure lookup fallback
  -o, --output string             output mode (JSON, json, tree, wide, yaml)
  -r, --recursive                 follow component reference nesting
      --repo string               repository name or spec
  -S, --scheme string             schema version
  -s, --sort stringArray          sort fields
```



#### Which issue(s) this PR fixes
<!--
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
#1189
  • Loading branch information
fabianburth authored Dec 13, 2024
1 parent 34064e7 commit 2e9fab3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions api/utils/cobrautils/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ Aliases:
Available Commands:{{range .Commands}}{{if (or .IsAvailableCommand (eq .Name "help"))}}
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if and .HasAvailableLocalFlags .IsAvailableCommand}}
Flags:
Options:
{{ flagUsages .LocalFlags | trimTrailingWhitespaces}}{{end}}{{if and .HasAvailableInheritedFlags .IsAvailableCommand}}
Global Flags:
Global Options:
{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}
Description:
Expand Down Expand Up @@ -44,10 +44,10 @@ Examples:
Available Commands:{{range .Commands}}{{if (or .IsAvailableCommand (eq .Name "help"))}}
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}
Flags:
Options:
{{ flagUsages .LocalFlags | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}}
Global Flags:
Global Options:
{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasHelpSubCommands}}
Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}}
Expand Down
4 changes: 2 additions & 2 deletions cmds/cliplugin/cmds/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ ocm check rhubarb — Determine Whether We Are In Rhubarb Season
Synopsis:
ocm check rhubarb <options>
Flags:
Options:
-d, --date string the date to ask for (MM/DD)
-h, --help help for check
Expand All @@ -106,7 +106,7 @@ ocm check rhubarb — Determine Whether We Are In Rhubarb Season
Synopsis:
ocm check rhubarb <options>
Flags:
Options:
-d, --date string the date to ask for (MM/DD)
-h, --help help for check
Expand Down
8 changes: 4 additions & 4 deletions cmds/subcmdplugin/cmds/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Synopsis:
Available Commands:
demo a demo command
Flags:
Options:
-h, --help help for group
Description:
Expand All @@ -83,7 +83,7 @@ ocm group demo — A Demo Command
Synopsis:
ocm group demo <options> [flags]
Flags:
Options:
-h, --help help for demo
--version string some overloaded option
Expand All @@ -107,7 +107,7 @@ Synopsis:
Available Commands:
demo a demo command
Flags:
Options:
-h, --help help for group
Description:
Expand All @@ -126,7 +126,7 @@ ocm group demo — A Demo Command
Synopsis:
ocm group demo <options> [flags]
Flags:
Options:
-h, --help help for demo
--version string some overloaded option
Expand Down

0 comments on commit 2e9fab3

Please sign in to comment.