Skip to content

Commit

Permalink
feature: rename exported func Repl into REPL
Browse files Browse the repository at this point in the history
  • Loading branch information
mvertes authored and traefiker committed Oct 8, 2019
1 parent 398b0e0 commit de5a6e1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
7 changes: 7 additions & 0 deletions .golangci.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,10 @@
[[issues.exclude-rules]]
path = "interp/.+_test\\.go"
linters = ["goconst"]

[[issues.exclude-rules]]
path = "interp/interp.go"
text = "`in` can be `io.Reader`"
[[issues.exclude-rules]]
path = "interp/interp.go"
text = "`out` can be `io.Writer`"
4 changes: 2 additions & 2 deletions cmd/yaegi/yaegi.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ func main() {
}

if interactive {
i.Repl(os.Stdin, os.Stdout)
i.REPL(os.Stdin, os.Stdout)
}
} else {
i.Repl(os.Stdin, os.Stdout)
i.REPL(os.Stdin, os.Stdout)
}
}
13 changes: 10 additions & 3 deletions interp/interp.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,9 @@ func (interp *Interpreter) Use(values Exports) {
}
}

// Repl performs a Read-Eval-Print-Loop on input file descriptor.
// Results are printed on output.
func (interp *Interpreter) Repl(in io.Reader, out io.Writer) {
// REPL performs a Read-Eval-Print-Loop on input reader.
// Results are printed on output writer.
func (interp *Interpreter) REPL(in io.Reader, out io.Writer) {
s := bufio.NewScanner(in)
prompt := getPrompt(in, out)
prompt()
Expand All @@ -358,6 +358,13 @@ func (interp *Interpreter) Repl(in io.Reader, out io.Writer) {
}
}

// Repl performs a Read-Eval-Print-Loop on input file descriptor.
// Results are printed on output.
// Deprecated: use REPL instead
func (interp *Interpreter) Repl(in, out *os.File) {
interp.REPL(in, out)
}

// getPrompt returns a function which prints a prompt only if input is a terminal.
func getPrompt(in io.Reader, out io.Writer) func() {
s, ok := in.(interface{ Stat() (os.FileInfo, error) })
Expand Down

0 comments on commit de5a6e1

Please sign in to comment.