mirror of
				https://github.com/docker/compose.git
				synced 2025-11-04 05:34:09 +01:00 
			
		
		
		
	cmd: consistent handling no-args commands (#9660)
Enforce args rejection for commands without args: * ls * version Additionally, docs for `restart` are fixed. Signed-off-by: piroux <pierre.roux01@gmail.com>
This commit is contained in:
		
							parent
							
								
									def189fae1
								
							
						
					
					
						commit
						38a18790ed
					
				@ -46,6 +46,7 @@ func listCommand(backend api.Service) *cobra.Command {
 | 
				
			|||||||
		RunE: Adapt(func(ctx context.Context, args []string) error {
 | 
							RunE: Adapt(func(ctx context.Context, args []string) error {
 | 
				
			||||||
			return runList(ctx, backend, lsOpts)
 | 
								return runList(ctx, backend, lsOpts)
 | 
				
			||||||
		}),
 | 
							}),
 | 
				
			||||||
 | 
							Args:              cobra.NoArgs,
 | 
				
			||||||
		ValidArgsFunction: noCompletion(),
 | 
							ValidArgsFunction: noCompletion(),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	lsCmd.Flags().StringVar(&lsOpts.Format, "format", "pretty", "Format the output. Values: [pretty | json].")
 | 
						lsCmd.Flags().StringVar(&lsOpts.Format, "format", "pretty", "Format the output. Values: [pretty | json].")
 | 
				
			||||||
 | 
				
			|||||||
@ -35,8 +35,8 @@ func restartCommand(p *projectOptions, backend api.Service) *cobra.Command {
 | 
				
			|||||||
		projectOptions: p,
 | 
							projectOptions: p,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	restartCmd := &cobra.Command{
 | 
						restartCmd := &cobra.Command{
 | 
				
			||||||
		Use:   "restart",
 | 
							Use:   "restart [SERVICE...]",
 | 
				
			||||||
		Short: "Restart containers",
 | 
							Short: "Restart service containers",
 | 
				
			||||||
		RunE: Adapt(func(ctx context.Context, args []string) error {
 | 
							RunE: Adapt(func(ctx context.Context, args []string) error {
 | 
				
			||||||
			return runRestart(ctx, backend, opts, args)
 | 
								return runRestart(ctx, backend, opts, args)
 | 
				
			||||||
		}),
 | 
							}),
 | 
				
			||||||
 | 
				
			|||||||
@ -37,7 +37,7 @@ func versionCommand() *cobra.Command {
 | 
				
			|||||||
	cmd := &cobra.Command{
 | 
						cmd := &cobra.Command{
 | 
				
			||||||
		Use:   "version",
 | 
							Use:   "version",
 | 
				
			||||||
		Short: "Show the Docker Compose version information",
 | 
							Short: "Show the Docker Compose version information",
 | 
				
			||||||
		Args:  cobra.MaximumNArgs(0),
 | 
							Args:  cobra.NoArgs,
 | 
				
			||||||
		RunE: func(cmd *cobra.Command, _ []string) error {
 | 
							RunE: func(cmd *cobra.Command, _ []string) error {
 | 
				
			||||||
			runVersion(opts)
 | 
								runVersion(opts)
 | 
				
			||||||
			return nil
 | 
								return nil
 | 
				
			||||||
 | 
				
			|||||||
@ -23,7 +23,7 @@ Docker Compose
 | 
				
			|||||||
| [`ps`](compose_ps.md) | List containers |
 | 
					| [`ps`](compose_ps.md) | List containers |
 | 
				
			||||||
| [`pull`](compose_pull.md) | Pull service images |
 | 
					| [`pull`](compose_pull.md) | Pull service images |
 | 
				
			||||||
| [`push`](compose_push.md) | Push service images |
 | 
					| [`push`](compose_push.md) | Push service images |
 | 
				
			||||||
| [`restart`](compose_restart.md) | Restart containers |
 | 
					| [`restart`](compose_restart.md) | Restart service containers |
 | 
				
			||||||
| [`rm`](compose_rm.md) | Removes stopped service containers |
 | 
					| [`rm`](compose_rm.md) | Removes stopped service containers |
 | 
				
			||||||
| [`run`](compose_run.md) | Run a one-off command on a service. |
 | 
					| [`run`](compose_run.md) | Run a one-off command on a service. |
 | 
				
			||||||
| [`start`](compose_start.md) | Start services |
 | 
					| [`start`](compose_start.md) | Start services |
 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +1,7 @@
 | 
				
			|||||||
# docker compose restart
 | 
					# docker compose restart
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<!---MARKER_GEN_START-->
 | 
					<!---MARKER_GEN_START-->
 | 
				
			||||||
Restart containers
 | 
					Restart service containers
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Options
 | 
					### Options
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -14,7 +14,7 @@ Restart containers
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
## Description
 | 
					## Description
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Restarts all stopped and running services.
 | 
					Restarts all stopped and running services, or the specified services only.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
If you make changes to your `compose.yml` configuration, these changes are not reflected
 | 
					If you make changes to your `compose.yml` configuration, these changes are not reflected
 | 
				
			||||||
after running this command. For example, changes to environment variables (which are added
 | 
					after running this command. For example, changes to environment variables (which are added
 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +1,7 @@
 | 
				
			|||||||
command: docker compose restart
 | 
					command: docker compose restart
 | 
				
			||||||
short: Restart containers
 | 
					short: Restart service containers
 | 
				
			||||||
long: |-
 | 
					long: |-
 | 
				
			||||||
    Restarts all stopped and running services.
 | 
					    Restarts all stopped and running services, or the specified services only.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    If you make changes to your `compose.yml` configuration, these changes are not reflected
 | 
					    If you make changes to your `compose.yml` configuration, these changes are not reflected
 | 
				
			||||||
    after running this command. For example, changes to environment variables (which are added
 | 
					    after running this command. For example, changes to environment variables (which are added
 | 
				
			||||||
@ -11,7 +11,7 @@ long: |-
 | 
				
			|||||||
    If you are looking to configure a service's restart policy, please refer to
 | 
					    If you are looking to configure a service's restart policy, please refer to
 | 
				
			||||||
    [restart](https://github.com/compose-spec/compose-spec/blob/master/spec.md#restart)
 | 
					    [restart](https://github.com/compose-spec/compose-spec/blob/master/spec.md#restart)
 | 
				
			||||||
    or [restart_policy](https://github.com/compose-spec/compose-spec/blob/master/deploy.md#restart_policy).
 | 
					    or [restart_policy](https://github.com/compose-spec/compose-spec/blob/master/deploy.md#restart_policy).
 | 
				
			||||||
usage: docker compose restart
 | 
					usage: docker compose restart [SERVICE...]
 | 
				
			||||||
pname: docker compose
 | 
					pname: docker compose
 | 
				
			||||||
plink: docker_compose.yaml
 | 
					plink: docker_compose.yaml
 | 
				
			||||||
options:
 | 
					options:
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user