forked from containers/toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/root: Use string template instead of function for usage
In version 1.1.2 of Cobra has been included a change[0] that changes the behaviour of how custom usage functions are printed. The change prepends "Error: " to the text. This is not desired since the usage text is not an error text. A workaround is to define a template string for the usage instead. The template uses the templating language of Go[1]. See the default template string in version 1.2.1[2]. This change has the positive benefit of getting more helpful usage messages. E.g., for command 'toolbox enter' the usage text is no longer "Run 'toolbox --help' for usage." but "Run 'toolbox enter --help' for usage.". Upstream issue: spf13/cobra#1532 [0] spf13/cobra#1044 [1] https://pkg.go.dev/text/template [2] https://github.com/spf13/cobra/blob/v1.2.1/command.go#L491
- Loading branch information
1 parent
1b26f97
commit 6af7c77
Showing
2 changed files
with
11 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters