(p *ProjectOptions, dockerCli command.Cli, backendOptions *BackendOptions)
| 38 | } |
| 39 | |
| 40 | func watchCommand(p *ProjectOptions, dockerCli command.Cli, backendOptions *BackendOptions) *cobra.Command { |
| 41 | watchOpts := watchOptions{ |
| 42 | ProjectOptions: p, |
| 43 | } |
| 44 | buildOpts := buildOptions{ |
| 45 | ProjectOptions: p, |
| 46 | } |
| 47 | cmd := &cobra.Command{ |
| 48 | Use: "watch [SERVICE...]", |
| 49 | Short: "Watch build context for service and rebuild/refresh containers when files are updated", |
| 50 | PreRunE: Adapt(func(ctx context.Context, args []string) error { |
| 51 | return nil |
| 52 | }), |
| 53 | RunE: AdaptCmd(func(ctx context.Context, cmd *cobra.Command, args []string) error { |
| 54 | if cmd.Parent().Name() == "alpha" { |
| 55 | logrus.Warn("watch command is now available as a top level command") |
| 56 | } |
| 57 | return runWatch(ctx, dockerCli, backendOptions, watchOpts, buildOpts, args) |
| 58 | }), |
| 59 | ValidArgsFunction: completeServiceNames(dockerCli, p), |
| 60 | } |
| 61 | |
| 62 | cmd.Flags().BoolVar(&buildOpts.quiet, "quiet", false, "hide build output") |
| 63 | cmd.Flags().BoolVar(&watchOpts.prune, "prune", true, "Prune dangling images on rebuild") |
| 64 | cmd.Flags().BoolVar(&watchOpts.noUp, "no-up", false, "Do not build & start services before watching") |
| 65 | return cmd |
| 66 | } |
| 67 | |
| 68 | func runWatch(ctx context.Context, dockerCli command.Cli, backendOptions *BackendOptions, watchOpts watchOptions, buildOpts buildOptions, services []string) error { |
| 69 | backend, err := compose.NewComposeService(dockerCli, backendOptions.Options...) |
no test coverage detected