MCPcopy Create free account
hub / github.com/docker/docker-agent / announceInstall

Function announceInstall

pkg/toolinstall/resolver.go:148–163  ·  view source on GitHub ↗

announceInstall prints a single user-visible line to stderr right before downloading a tool, so the user understands what the upcoming `go install` / GitHub-release chatter is about. We intentionally avoid stdout so this never gets piped into the agent's prompt or programmatic output. fatih/color's

(command, pkgName, version string)

Source from the content-addressed store, hash-verified

146// plain text. Decide based on stderr explicitly and force colour on
147// the local *color.Color values; honour NO_COLOR / TERM=dumb.
148func announceInstall(command, pkgName, version string) {
149 if stderrSupportsColor() {
150 // fatih/color's package-level NoColor is set from stdout's TTY
151 // state, so when stdout is piped but stderr is still a TTY the
152 // SprintFunc helpers would silently strip ANSI codes. Force the
153 // local colours on after we've decided stderr can handle them.
154 bold := color.New(color.Bold)
155 bold.EnableColor()
156 faint := color.New(color.Faint)
157 faint.EnableColor()
158 fmt.Fprintf(os.Stderr, "Installing %s %s\n",
159 bold.Sprint(command), faint.Sprintf("(%s@%s)", pkgName, version))
160 return
161 }
162 fmt.Fprintf(os.Stderr, "Installing %s (%s@%s)\n", command, pkgName, version)
163}
164
165// stderrSupportsColor reports whether ANSI escapes are safe to write
166// to os.Stderr.

Callers 1

doInstallFunction · 0.85

Calls 2

stderrSupportsColorFunction · 0.85
NewMethod · 0.45

Tested by

no test coverage detected