Skip to content

Commit

Permalink
Handle --no-build and --watch args
Browse files Browse the repository at this point in the history
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
  • Loading branch information
jhrotko committed Mar 26, 2024
1 parent 4b7b6ad commit ac3cb17
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmd/compose/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ func validateFlags(up *upOptions, create *createOptions) error {
}
up.Detach = true
}
if create.Build && create.noBuild {
return fmt.Errorf("--build and --no-build are incompatible")
if create.noBuild && (create.Build || up.watch) {
return fmt.Errorf("--no-build is incompatible with --build and --watch")
}
if up.Detach && (up.attachDependencies || up.cascadeStop || len(up.attach) > 0) {
return fmt.Errorf("--detach cannot be combined with --abort-on-container-exit, --attach or --attach-dependencies")
Expand Down
6 changes: 6 additions & 0 deletions cmd/formatter/shortcut.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@ func (lk *LogKeyboard) StartWatch(ctx context.Context, project *types.Project, o
} else {
eg.Go(tracing.EventWrapFuncForErrGroup(ctx, "menu/watch", tracing.SpanOptions{},
func(ctx context.Context) error {
if options.Create.Build == nil {
err := fmt.Errorf("Cannot run watch mode with flag --no-build")
lk.keyboardError("Watch", err)
return err
}

lk.Watch.newContext(ctx)
buildOpts := *options.Create.Build
buildOpts.Quiet = true
Expand Down

0 comments on commit ac3cb17

Please sign in to comment.