Skip to content

Commit

Permalink
Enforce consistent args rejection for no-args commands: ls, restart, …
Browse files Browse the repository at this point in the history
…version

Based on #9158 which enforced it for the down command

Signed-off-by: piroux <[email protected]>
  • Loading branch information
piroux committed Jul 16, 2022
1 parent d85751f commit f3af3e6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions cmd/compose/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func listCommand(backend api.Service) *cobra.Command {
RunE: Adapt(func(ctx context.Context, args []string) error {
return runList(ctx, backend, lsOpts)
}),
Args: cobra.NoArgs,
ValidArgsFunction: noCompletion(),
}
lsCmd.Flags().StringVar(&lsOpts.Format, "format", "pretty", "Format the output. Values: [pretty | json].")
Expand Down
1 change: 1 addition & 0 deletions cmd/compose/restart.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func restartCommand(p *projectOptions, backend api.Service) *cobra.Command {
RunE: Adapt(func(ctx context.Context, args []string) error {
return runRestart(ctx, backend, opts, args)
}),
Args: cobra.NoArgs,
ValidArgsFunction: serviceCompletion(p),
}
flags := restartCmd.Flags()
Expand Down
2 changes: 1 addition & 1 deletion cmd/compose/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func versionCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "version",
Short: "Show the Docker Compose version information",
Args: cobra.MaximumNArgs(0),
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, _ []string) error {
runVersion(opts)
return nil
Expand Down

0 comments on commit f3af3e6

Please sign in to comment.