diff options
| author | tjp <tjp@ctrl-c.club> | 2024-01-05 12:19:19 -0700 |
|---|---|---|
| committer | tjp <tjp@ctrl-c.club> | 2024-01-05 12:19:19 -0700 |
| commit | 65218373fdc7e32ef175425c25ba9e90ac31fac6 (patch) | |
| tree | e8714b620a0cb1e441735d346e37a3724d722f40 | |
| parent | 78e9e89b45e8f940f87ccaf7678cacab3d47fdcc (diff) | |
multiple semicolon-separated commands on a prompt line
| -rw-r--r-- | main.go | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -5,6 +5,7 @@ import ( "io" "log" "os" + "strings" "github.com/chzyer/readline" ) @@ -51,11 +52,14 @@ func main() { log.Fatal(err) } - if c, err := ParseCommand(line); err != nil { - writeError(err.Error()) - } else if err := RunCommand(conf, c, state); err != nil { - writeError(err.Error()) + for _, cmd := range strings.Split(line, ";") { + if c, err := ParseCommand(strings.TrimSpace(cmd)); err != nil { + writeError(err.Error()) + } else if err := RunCommand(conf, c, state); err != nil { + writeError(err.Error()) + } } + } } |
