(p *ProjectOptions, dockerCli command.Cli, backendOptions *BackendOptions)
| 35 | } |
| 36 | |
| 37 | func exportCommand(p *ProjectOptions, dockerCli command.Cli, backendOptions *BackendOptions) *cobra.Command { |
| 38 | options := exportOptions{ |
| 39 | ProjectOptions: p, |
| 40 | } |
| 41 | cmd := &cobra.Command{ |
| 42 | Use: "export [OPTIONS] SERVICE", |
| 43 | Short: "Export a service container's filesystem as a tar archive", |
| 44 | Args: cobra.MinimumNArgs(1), |
| 45 | PreRunE: Adapt(func(ctx context.Context, args []string) error { |
| 46 | options.service = args[0] |
| 47 | return nil |
| 48 | }), |
| 49 | RunE: Adapt(func(ctx context.Context, args []string) error { |
| 50 | return runExport(ctx, dockerCli, backendOptions, options) |
| 51 | }), |
| 52 | ValidArgsFunction: completeServiceNames(dockerCli, p), |
| 53 | } |
| 54 | |
| 55 | flags := cmd.Flags() |
| 56 | flags.IntVar(&options.index, "index", 0, "index of the container if service has multiple replicas.") |
| 57 | flags.StringVarP(&options.output, "output", "o", "", "Write to a file, instead of STDOUT") |
| 58 | |
| 59 | return cmd |
| 60 | } |
| 61 | |
| 62 | func runExport(ctx context.Context, dockerCli command.Cli, backendOptions *BackendOptions, options exportOptions) error { |
| 63 | projectName, err := options.toProjectName(ctx, dockerCli) |
no test coverage detected