Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit 90058ec

Browse files
committed
ref: suggest management and check needed flags
only display the hints in main case, without progress, output or push flags Signed-off-by: Yves Brissaud <yves.brissaud@docker.com>
1 parent 62c2e00 commit 90058ec

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

cli/mobycli/exec.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,18 @@ func Exec(_ *cobra.Command) {
111111
}
112112
commandArgs := os.Args[1:]
113113
command := metrics.GetCommand(commandArgs)
114-
if (command == "build" || command == "pull") && !metrics.HasQuietFlag(commandArgs) {
115-
var image string
116-
if command == "pull" {
117-
image = pulledImageFromArgs(commandArgs)
114+
if !metrics.HasQuietFlag(commandArgs) {
115+
switch command {
116+
case "build": // only on regular build, not on buildx build
117+
displayScoutQuickViewSuggestMsgOnBuild(commandArgs)
118+
case "pull":
119+
displayScoutQuickViewSuggestMsgOnPull(commandArgs)
120+
case "login":
121+
displayPATSuggestMsg(commandArgs)
122+
default:
118123
}
119-
displayScoutQuickViewSuggestMsg(image)
120-
}
121-
if command == "login" && !metrics.HasQuietFlag(commandArgs) {
122-
displayPATSuggestMsg(commandArgs)
123124
}
125+
124126
metricsClient.Track(
125127
metrics.CmdResult{
126128
ContextType: store.DefaultContextType,

cli/mobycli/scout_suggest.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import (
2222
"strconv"
2323
"strings"
2424

25+
"github.com/docker/compose/v2/pkg/utils"
26+
2527
"github.com/fatih/color"
2628
)
2729

@@ -34,6 +36,21 @@ func isDockerScoutHintsEnabled() bool {
3436
return err != nil || enabled
3537
}
3638

39+
func displayScoutQuickViewSuggestMsgOnPull(args []string) {
40+
image := pulledImageFromArgs(args)
41+
displayScoutQuickViewSuggestMsg(image)
42+
}
43+
44+
func displayScoutQuickViewSuggestMsgOnBuild(args []string) {
45+
// only display the hint in the main case, build command and not buildx build, no output flag, no progress flag, no push flag
46+
if utils.StringContains(args, "--output") || utils.StringContains(args, "-o") ||
47+
utils.StringContains(args, "--progress") ||
48+
utils.StringContains(args, "--push") {
49+
return
50+
}
51+
displayScoutQuickViewSuggestMsg("")
52+
}
53+
3754
func displayScoutQuickViewSuggestMsg(image string) {
3855
if !isDockerScoutHintsEnabled() {
3956
return

0 commit comments

Comments
 (0)