Skip to content

Commit dd5614e

Browse files
committed
Handle --no-build and --watch args
Signed-off-by: Joana Hrotko <[email protected]>
1 parent 4b7b6ad commit dd5614e

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

cmd/compose/up.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ func upCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service, ex
137137
return upCmd
138138
}
139139

140+
//nolint:gocyclo
140141
func validateFlags(up *upOptions, create *createOptions) error {
141142
if up.exitCodeFrom != "" {
142143
up.cascadeStop = true
@@ -159,6 +160,9 @@ func validateFlags(up *upOptions, create *createOptions) error {
159160
if create.recreateDeps && create.noRecreate {
160161
return fmt.Errorf("--always-recreate-deps and --no-recreate are incompatible")
161162
}
163+
if create.noBuild && up.watch {
164+
return fmt.Errorf("--no-build and --watch are incompatible")
165+
}
162166
return nil
163167
}
164168

cmd/formatter/shortcut.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,12 @@ func (lk *LogKeyboard) StartWatch(ctx context.Context, project *types.Project, o
259259
} else {
260260
eg.Go(tracing.EventWrapFuncForErrGroup(ctx, "menu/watch", tracing.SpanOptions{},
261261
func(ctx context.Context) error {
262+
if options.Create.Build == nil {
263+
err := fmt.Errorf("Cannot run watch mode with flag --no-build")
264+
lk.keyboardError("Watch", err)
265+
return err
266+
}
267+
262268
lk.Watch.newContext(ctx)
263269
buildOpts := *options.Create.Build
264270
buildOpts.Quiet = true

0 commit comments

Comments
 (0)