mirror of
https://github.com/wader/fq.git
synced 2024-12-28 08:02:28 +03:00
0a043f9096
Now repl, slurp and help implemented using same query rewrite. Include filename context in error if possible. Add spew function that does opposite of slurp. Start of help infra, not done or documented yet. Show error pointer on parse error. Rename internal eval to _eval and make eval be wrapper that does rewrite and has various eror handling etc. Nicer repl, slupr and help errors.
44 lines
1005 B
Plaintext
44 lines
1005 B
Plaintext
$ fq -ni
|
|
null> help
|
|
Type expression to evaluate
|
|
\t Completion
|
|
Up/Down History
|
|
^C Interrupt execution
|
|
... | repl Start a new REPL
|
|
^D Exit REPL
|
|
null> help | abc
|
|
error: expr: function not defined: abc/0
|
|
null> help | 1
|
|
error: help must be alone or last in pipeline. ex: help(length) or ... | help
|
|
null> abc | help
|
|
error: expr: function not defined: abc/0
|
|
null> "a"+1 | help
|
|
error: cannot add: string ("a") and number (1)
|
|
"value help"
|
|
[]
|
|
null> help(length)
|
|
length: Length of string, array, object, etc
|
|
- For string number of unicode codepoints
|
|
- For array number of elements in array
|
|
- For object number of key-value pairs
|
|
- For null zero
|
|
- For number the number itself
|
|
- For boolean is an error
|
|
|
|
Examples:
|
|
> [1,2,3] | length
|
|
3
|
|
> "abc" | length
|
|
3
|
|
> {"a":1,"b":2} | length
|
|
2
|
|
> null | length
|
|
0
|
|
> 123 | length
|
|
123
|
|
> true | length
|
|
error: length cannot be applied to: boolean (true)
|
|
null> help(1;2)
|
|
error: expr: help must be last in pipeline. ex: help(length) or ... | help
|
|
null> ^D
|