diff --git a/repl/commands.go b/repl/commands.go new file mode 100644 index 0000000..dc44032 --- /dev/null +++ b/repl/commands.go @@ -0,0 +1,12 @@ +package repl + +import ( + "os" + "os/exec" +) + +func clearOutput() { + cmd := exec.Command("clear") + cmd.Stdout = os.Stdout + cmd.Run() +} diff --git a/repl/repl.go b/repl/repl.go index 7fa4057..95d30e0 100644 --- a/repl/repl.go +++ b/repl/repl.go @@ -21,6 +21,12 @@ func Start(in io.Reader, out io.Writer) { return } line := scanner.Text() + + if line == "clear" { + clearOutput() + continue + } + l := lexer.New(line) for tok := l.NextToken(); tok.Type != token.EOF; tok = l.NextToken() {