| Sketch🕴️ | 0020265 | 2026-02-28 21:10:00 +0400 | [diff] [blame^] | 1 | package tools |
| 2 | |||||
| 3 | import ( | ||||
| 4 | "os/exec" | ||||
| 5 | ) | ||||
| 6 | |||||
| 7 | type BashCommandArgs struct { | ||||
| 8 | Command string `json:"command" jsonschema:"title=command,description=bash command to run,required"` | ||||
| 9 | } | ||||
| 10 | |||||
| 11 | func BashCommand(args BashCommandArgs) (string, error) { | ||||
| 12 | cmd := exec.Command("bash", "-c", args.Command) | ||||
| 13 | if out, err := cmd.Output(); err != nil { | ||||
| 14 | return "", err | ||||
| 15 | } else { | ||||
| 16 | return string(out), nil | ||||
| 17 | } | ||||
| 18 | } | ||||