mirror of
https://github.com/wader/fq.git
synced 2024-09-20 08:18:51 +03:00
interp: Some better naming and typos
This commit is contained in:
parent
3db11d3fa8
commit
1fe5d95307
@ -34,7 +34,7 @@ import (
|
||||
// TODO: make it nicer somehow? generate generators? remove from struct?
|
||||
func (i *Interp) makeFunctions() []Function {
|
||||
fs := []Function{
|
||||
{[]string{"readline"}, 0, 2, i.readline, nil},
|
||||
{[]string{"_readline"}, 0, 2, i.readline, nil},
|
||||
{[]string{"eval"}, 1, 2, nil, i.eval},
|
||||
{[]string{"stdin"}, 0, 0, nil, i.makeStdioFn(i.os.Stdin())},
|
||||
{[]string{"stdout"}, 0, 0, nil, i.makeStdioFn(i.os.Stdout())},
|
||||
|
@ -330,7 +330,7 @@ def _repl($opts): #:: a|(Opts) => @
|
||||
def _read_expr:
|
||||
# both _prompt and _complete want arrays
|
||||
( . as $c
|
||||
| readline(_prompt; "_complete")
|
||||
| _readline(_prompt; "_complete")
|
||||
| if trim == "" then
|
||||
$c | _read_expr
|
||||
end
|
||||
@ -345,7 +345,7 @@ def _repl($opts): #:: a|(Opts) => @
|
||||
# TODO: nicer way to set filename for error message
|
||||
catch (. | .filename = "repl")
|
||||
| if _query_pipe_last | _query_is_func("repl") then
|
||||
( _query_slurp_wrap(_query_func_rename("_repl_iter"))
|
||||
( _query_slurp_wrap(_query_func_rename("_repl_slurp"))
|
||||
| _query_tostring as $wrap_expr
|
||||
| $c
|
||||
| _repl_eval($wrap_expr)
|
||||
@ -361,7 +361,7 @@ def _repl($opts): #:: a|(Opts) => @
|
||||
if . == "interrupt" then empty
|
||||
elif . == "eof" then error("break")
|
||||
elif _eval_is_compile_error then _repl_on_error
|
||||
else error(.)
|
||||
else error
|
||||
end
|
||||
);
|
||||
( _options_stack(. + [$opts]) as $_
|
||||
@ -371,13 +371,13 @@ def _repl($opts): #:: a|(Opts) => @
|
||||
)
|
||||
);
|
||||
|
||||
def _repl_iter($opts): _repl($opts);
|
||||
def _repl_iter: _repl({});
|
||||
def _repl_slurp($opts): _repl($opts);
|
||||
def _repl_slurp: _repl({});
|
||||
|
||||
# just gives error, call appearing last will be renamed to _repl_iter
|
||||
# just gives error, call appearing last will be renamed to _repl_slurp
|
||||
def repl($_):
|
||||
if options.repl then error("repl must be last")
|
||||
else error("repl can only be be used from repl")
|
||||
else error("repl can only be used from interactive repl")
|
||||
end;
|
||||
def repl: repl(null);
|
||||
|
||||
|
2
pkg/interp/testdata/repl.fqtest
vendored
2
pkg/interp/testdata/repl.fqtest
vendored
@ -61,4 +61,4 @@ $ fq -i '[1,2,3]'
|
||||
$ fq -n repl
|
||||
exitcode: 5
|
||||
stderr:
|
||||
error: repl can only be be used from repl
|
||||
error: repl can only be used from interactive repl
|
||||
|
Loading…
Reference in New Issue
Block a user