(p *ProjectOptions, dockerCli command.Cli, backendOptions *BackendOptions)
| 38 | } |
| 39 | |
| 40 | func attachCommand(p *ProjectOptions, dockerCli command.Cli, backendOptions *BackendOptions) *cobra.Command { |
| 41 | opts := attachOpts{ |
| 42 | composeOptions: &composeOptions{ |
| 43 | ProjectOptions: p, |
| 44 | }, |
| 45 | } |
| 46 | runCmd := &cobra.Command{ |
| 47 | Use: "attach [OPTIONS] SERVICE", |
| 48 | Short: "Attach local standard input, output, and error streams to a service's running container", |
| 49 | Args: cobra.MinimumNArgs(1), |
| 50 | PreRunE: Adapt(func(ctx context.Context, args []string) error { |
| 51 | opts.service = args[0] |
| 52 | return nil |
| 53 | }), |
| 54 | RunE: Adapt(func(ctx context.Context, args []string) error { |
| 55 | return runAttach(ctx, dockerCli, backendOptions, opts) |
| 56 | }), |
| 57 | ValidArgsFunction: completeServiceNames(dockerCli, p), |
| 58 | } |
| 59 | |
| 60 | runCmd.Flags().IntVar(&opts.index, "index", 0, "index of the container if service has multiple replicas.") |
| 61 | runCmd.Flags().StringVarP(&opts.detachKeys, "detach-keys", "", "", "Override the key sequence for detaching from a container.") |
| 62 | |
| 63 | runCmd.Flags().BoolVar(&opts.noStdin, "no-stdin", false, "Do not attach STDIN") |
| 64 | runCmd.Flags().BoolVar(&opts.proxy, "sig-proxy", true, "Proxy all received signals to the process") |
| 65 | return runCmd |
| 66 | } |
| 67 | |
| 68 | func runAttach(ctx context.Context, dockerCli command.Cli, backendOptions *BackendOptions, opts attachOpts) error { |
| 69 | projectName, err := opts.toProjectName(ctx, dockerCli) |
no test coverage detected