From dd5614ec3bc0e75dc03767c18c1c60dc6884870a Mon Sep 17 00:00:00 2001 From: Joana Hrotko Date: Tue, 26 Mar 2024 17:53:50 +0000 Subject: [PATCH] Handle --no-build and --watch args Signed-off-by: Joana Hrotko --- cmd/compose/up.go | 4 ++++ cmd/formatter/shortcut.go | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/cmd/compose/up.go b/cmd/compose/up.go index 1b458e3a0..c37d541c0 100644 --- a/cmd/compose/up.go +++ b/cmd/compose/up.go @@ -137,6 +137,7 @@ func upCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service, ex return upCmd } +//nolint:gocyclo func validateFlags(up *upOptions, create *createOptions) error { if up.exitCodeFrom != "" { up.cascadeStop = true @@ -159,6 +160,9 @@ func validateFlags(up *upOptions, create *createOptions) error { if create.recreateDeps && create.noRecreate { return fmt.Errorf("--always-recreate-deps and --no-recreate are incompatible") } + if create.noBuild && up.watch { + return fmt.Errorf("--no-build and --watch are incompatible") + } return nil } diff --git a/cmd/formatter/shortcut.go b/cmd/formatter/shortcut.go index feb3eb95f..831a5e4b4 100644 --- a/cmd/formatter/shortcut.go +++ b/cmd/formatter/shortcut.go @@ -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