mirror of
https://github.com/docker/compose.git
synced 2026-08-28 12:23:49 +00:00
add alpha command to test dry-run
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
This commit is contained in:
parent
5081ab0507
commit
eb59b0e265
6 changed files with 59 additions and 7 deletions
|
|
@ -15,6 +15,8 @@
|
|||
package compose
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/docker/compose/v2/pkg/api"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
|
@ -29,6 +31,27 @@ func alphaCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
|
|||
"experimentalCLI": "true",
|
||||
},
|
||||
}
|
||||
cmd.AddCommand(watchCommand(p, backend))
|
||||
cmd.AddCommand(
|
||||
watchCommand(p, backend),
|
||||
dryRunRedirectCommand(p),
|
||||
)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// Temporary alpha command as the dry-run will be implemented with a flag
|
||||
func dryRunRedirectCommand(p *ProjectOptions) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "dry-run -- [COMMAND...]",
|
||||
Short: "EXPERIMENTAL - Dry run command allow you to test a command without applying changes",
|
||||
PreRunE: Adapt(func(ctx context.Context, args []string) error {
|
||||
return nil
|
||||
}),
|
||||
RunE: AdaptCmd(func(ctx context.Context, cmd *cobra.Command, args []string) error {
|
||||
rootCmd := cmd.Root()
|
||||
rootCmd.SetArgs(append([]string{"compose", "--dry-run"}, args...))
|
||||
return rootCmd.Execute()
|
||||
}),
|
||||
ValidArgsFunction: completeServiceNames(p),
|
||||
}
|
||||
return cmd
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue