fix: use full root name for cmd help prefixes (#873)

This commit is contained in:
Luke Kingland 2022-03-02 19:18:42 +09:00 committed by GitHub
parent 02fa79e8e9
commit 3f30c91116
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 2 deletions

View File

@ -172,7 +172,7 @@ func runCreateHelp(cmd *cobra.Command, args []string, newClient ClientFactory) {
Name string
}{
Options: options,
Name: cmd.Root().Name(),
Name: cmd.Root().Use,
}
if err := tpl.Execute(cmd.OutOrStdout(), data); err != nil {
fmt.Fprintf(cmd.ErrOrStderr(), "unable to display help text: %v", err)

View File

@ -183,7 +183,7 @@ func runInvokeHelp(cmd *cobra.Command, args []string, newClient ClientFactory) {
var data = struct {
Name string
}{
Name: cmd.Root().Name(),
Name: cmd.Root().Use,
}
if err := tpl.Execute(cmd.OutOrStdout(), data); err != nil {

View File

@ -43,6 +43,8 @@ func NewRootCmd(config RootCommandConfig) (*cobra.Command, error) {
var err error
root := &cobra.Command{
// Use must be set to exactly config.Name, as this field is overloaded to
// be used in subcommand help text as the command with possible prefix:
Use: config.Name,
Short: "Serverless Functions",
SilenceErrors: true, // we explicitly handle errors in Execute()