(p *ProjectOptions, dockerCli command.Cli, backendOptions *BackendOptions)
| 34 | } |
| 35 | |
| 36 | func 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 | |
| 58 | func runGenerate(ctx context.Context, dockerCli command.Cli, backendOptions *BackendOptions, opts generateOptions, containers []string) error { |
| 59 | _, _ = fmt.Fprintln(os.Stderr, "generate command is EXPERIMENTAL") |
no test coverage detected