MCPcopy Index your code
hub / github.com/bootdotdev/bootdev / runCLICommand

Function runCLICommand

checks/cli.go:14–40  ·  view source on GitHub ↗
(command api.CLIStepCLICommand, variables map[string]string)

Source from the content-addressed store, hash-verified

12)
13
14func runCLICommand(command api.CLIStepCLICommand, variables map[string]string) (result api.CLICommandResult) {
15 finalCommand := InterpolateVariables(command.Command, variables)
16 result.FinalCommand = finalCommand
17 result.Command = command
18
19 var cmd *exec.Cmd
20
21 if runtime.GOOS == "windows" {
22 cmd = exec.Command("powershell", "-Command", finalCommand)
23 } else {
24 cmd = exec.Command("sh", "-c", finalCommand)
25 }
26
27 cmd.Env = append(os.Environ(), "LANG=en_US.UTF-8")
28 b, err := cmd.CombinedOutput()
29 if ee, ok := err.(*exec.ExitError); ok {
30 result.ExitCode = ee.ExitCode()
31 } else if err != nil {
32 result.ExitCode = -2
33 }
34 result.Stdout = strings.TrimRight(string(b), " \n\t\r")
35 if command.StdoutFilterTmdl != nil {
36 result.Stdout = ExtractTmdlBlock(result.Stdout, *command.StdoutFilterTmdl)
37 }
38 result.Variables = maps.Clone(variables)
39 return result
40}
41
42func prettyPrintCLICommand(test api.CLICommandTest, variables map[string]string) string {
43 if test.ExitCode != nil {

Callers 1

CLIChecksFunction · 0.85

Calls 2

InterpolateVariablesFunction · 0.85
ExtractTmdlBlockFunction · 0.85

Tested by

no test coverage detected