Skip to content

Commit

Permalink
replace [flags] with [options] in use line
Browse files Browse the repository at this point in the history
  • Loading branch information
djelusic committed Nov 8, 2021
1 parent 3548ee4 commit 4700034
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 5 additions & 5 deletions cli/cmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ func newAwsCommand() *cobra.Command {
Short: "AWS node subcommand",
Args: cobra.NoArgs,
}
cmd.AddCommand(newAwsInstallCommand())
cmd.AddCommand(newAwsUninstallCommand())
addCommand(cmd, newAwsInstallCommand())
addCommand(cmd, newAwsUninstallCommand())
return cmd
}

Expand Down Expand Up @@ -356,8 +356,8 @@ which can be managed and configured separately.
Stages can be deployed to any node in the workspace.`,
}
cmd.AddCommand(newStageNewCommand())
cmd.AddCommand(newStageDestroyCommand())
addCommand(cmd, newStageNewCommand())
addCommand(cmd, newStageDestroyCommand())
return cmd
}

Expand Down Expand Up @@ -428,7 +428,7 @@ func newGenerateCommand() *cobra.Command {
Use: "generate",
Short: "Automatically generate code in the project",
}
cmd.AddCommand(newGenerateApiCommand())
addCommand(cmd, newGenerateApiCommand())
return cmd
}

Expand Down
10 changes: 9 additions & 1 deletion cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func root() *cobra.Command {

add := func(factory func() *cobra.Command) {
sub := factory()
cmd.AddCommand(sub)
addCommand(cmd, sub)
}
subCommands := []func() *cobra.Command{
newEnvCommand,
Expand Down Expand Up @@ -190,3 +190,11 @@ Please check the following rules when naming projects, stages and functions:

ui.Error(err)
}

func addCommand(target, cmd *cobra.Command) {
cmd.DisableFlagsInUseLine = true
if cmd.HasAvailableFlags() && !strings.Contains(cmd.Use, "[options]") {
cmd.Use += " [options]"
}
target.AddCommand(cmd)
}

0 comments on commit 4700034

Please sign in to comment.