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

Function watchCommand

cmd/compose/watch.go:40–66  ·  cmd/compose/watch.go::watchCommand
(p *ProjectOptions, dockerCli command.Cli, backendOptions *BackendOptions)

Source from the content-addressed store, hash-verified

38}
39
40func 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
68func runWatch(ctx context.Context, dockerCli command.Cli, backendOptions *BackendOptions, watchOpts watchOptions, buildOpts buildOptions, services []string) error {
69 backend, err := compose.NewComposeService(dockerCli, backendOptions.Options...)

Callers 1

RootCommandFunction · 0.85

Calls 5

AdaptFunction · 0.85
AdaptCmdFunction · 0.85
runWatchFunction · 0.85
completeServiceNamesFunction · 0.85
NameMethod · 0.45

Tested by

no test coverage detected