MCPcopy Create free account
hub / github.com/ahmedakef/goshell / runProgram

Method runProgram

manager.go:104–129  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

102}
103
104func (m *Manager) runProgram() (string, error) {
105 commands := m.prepareCommands()
106 program, err := prepareProgram(m.templatePath, commands, m.functions)
107 if err != nil {
108 return "", err
109 }
110
111 // Save the substituted template to the output file
112 err = os.WriteFile(m.programPath, []byte(program), fs.FileMode(0644))
113 if err != nil {
114 return "", err
115 }
116
117 err = formatProgram(m.programPath)
118 if err != nil {
119 return "", err
120 }
121
122 cmd := exec.Command("go", "run", m.programPath)
123 output, err := cmd.CombinedOutput()
124 if err != nil {
125 fmt.Println(string(output))
126 return "", err
127 }
128 return string(output), nil
129}
130
131func (m *Manager) getProgram() (string, error) {
132 commands := m.prepareCommands()

Callers 2

TestManager_RunProgramFunction · 0.80
mainFunction · 0.80

Calls 3

prepareCommandsMethod · 0.95
prepareProgramFunction · 0.85
formatProgramFunction · 0.85

Tested by 1

TestManager_RunProgramFunction · 0.64