MCPcopy
hub / github.com/docker/compose / generateCommand

Function generateCommand

cmd/compose/generate.go:36–56  ·  view source on GitHub ↗
(p *ProjectOptions, dockerCli command.Cli, backendOptions *BackendOptions)

Source from the content-addressed store, hash-verified

34}
35
36func generateCommand(p *ProjectOptions, dockerCli command.Cli, backendOptions *BackendOptions) *cobra.Command {
37 opts := generateOptions{
38 ProjectOptions: p,
39 }
40
41 cmd := &cobra.Command{
42 Use: "generate [OPTIONS] [CONTAINERS...]",
43 Short: "EXPERIMENTAL - Generate a Compose file from existing containers",
44 PreRunE: Adapt(func(ctx context.Context, args []string) error {
45 return nil
46 }),
47 RunE: Adapt(func(ctx context.Context, args []string) error {
48 return runGenerate(ctx, dockerCli, backendOptions, opts, args)
49 }),
50 }
51
52 cmd.Flags().StringVar(&opts.ProjectName, "name", "", "Project name to set in the Compose file")
53 cmd.Flags().StringVar(&opts.ProjectDir, "project-dir", "", "Directory to use for the project")
54 cmd.Flags().StringVar(&opts.Format, "format", "yaml", "Format the output. Values: [yaml | json]")
55 return cmd
56}
57
58func runGenerate(ctx context.Context, dockerCli command.Cli, backendOptions *BackendOptions, opts generateOptions, containers []string) error {
59 _, _ = fmt.Fprintln(os.Stderr, "generate command is EXPERIMENTAL")

Callers 1

alphaCommandFunction · 0.85

Calls 2

AdaptFunction · 0.85
runGenerateFunction · 0.85

Tested by

no test coverage detected