Skip to content

Commit

Permalink
add clear func to repl
Browse files Browse the repository at this point in the history
  • Loading branch information
54L1M committed Jan 27, 2024
1 parent 8a1fe2c commit df27994
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions repl/commands.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package repl

import (
"os"
"os/exec"
)

func clearOutput() {
cmd := exec.Command("clear")
cmd.Stdout = os.Stdout
cmd.Run()
}
6 changes: 6 additions & 0 deletions repl/repl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit df27994

Please sign in to comment.