MCPcopy
hub / github.com/slimtoolkit/slim / OnCommand

Function OnCommand

pkg/app/master/command/version/handler.go:20–50  ·  view source on GitHub ↗

OnCommand implements the 'version' command

(
	xc *app.ExecutionContext,
	doDebug, inContainer, isDSImage bool,
	clientConfig *config.DockerClient)

Source from the content-addressed store, hash-verified

18
19// OnCommand implements the 'version' command
20func OnCommand(
21 xc *app.ExecutionContext,
22 doDebug, inContainer, isDSImage bool,
23 clientConfig *config.DockerClient) {
24 logger := log.WithFields(log.Fields{"app": "slim", "cmd": cmd.Version})
25
26 client, err := dockerclient.New(clientConfig)
27 if err == dockerclient.ErrNoDockerInfo {
28 exitMsg := "missing Docker connection info"
29 if inContainer && isDSImage {
30 exitMsg = "make sure to pass the Docker connect parameters to the slim app container"
31 }
32
33 xc.Out.Info("docker.connect.error",
34 ovars{
35 "message": exitMsg,
36 })
37
38 exitCode := -777
39 xc.Out.State("exited",
40 ovars{
41 "exit.code": exitCode,
42 "version": v.Current(),
43 "location": fsutil.ExeDir(),
44 })
45 xc.Exit(exitCode)
46 }
47 errutil.FailOn(err)
48
49 version.Print(xc, Name, logger, client, true, inContainer, isDSImage)
50}

Callers 1

cli.goFile · 0.70

Calls 6

NewFunction · 0.92
ExeDirFunction · 0.92
FailOnFunction · 0.92
ExitMethod · 0.80
StateMethod · 0.65
InfoMethod · 0.45

Tested by

no test coverage detected