ecli.doc: correction and improvement
This commit is contained in:
+44
-19
@@ -34,6 +34,7 @@ Expression Calculator Interactive Tool
|
|||||||
The tool combines the expression evaluation capabilities of the Expr package with an interactive shell environment, making it ideal for:
|
The tool combines the expression evaluation capabilities of the Expr package with an interactive shell environment, making it ideal for:
|
||||||
|
|
||||||
- Interactive expression testing and prototyping
|
- Interactive expression testing and prototyping
|
||||||
|
- Command history survival across sessions
|
||||||
- Batch expression evaluation from scripts
|
- Batch expression evaluation from scripts
|
||||||
- Data processing and transformation
|
- Data processing and transformation
|
||||||
- Mathematical computations with fractions and complex operators
|
- Mathematical computations with fractions and complex operators
|
||||||
@@ -61,7 +62,7 @@ Start the interactive REPL:
|
|||||||
./ecli
|
./ecli
|
||||||
----
|
----
|
||||||
|
|
||||||
You'll see the prompt `>>> ` where you can enter expressions to evaluate.
|
You'll see the prompt `>>>` where you can enter expressions to evaluate.
|
||||||
|
|
||||||
=== Command Line Options
|
=== Command Line Options
|
||||||
|
|
||||||
@@ -89,11 +90,14 @@ Within the REPL, you can use the following commands:
|
|||||||
|===
|
|===
|
||||||
| Command | Description
|
| Command | Description
|
||||||
|
|
||||||
| `help` | Display available commands and command-line options
|
| `base [2\|8\|10\|16]` | Set the integer output base. Use without arguments to show current base
|
||||||
| `exit` | Exit the REPL
|
| `exit` | Exit the REPL
|
||||||
| `multiline` | Toggle multi-line input mode for complex expressions
|
| `help` | Display available commands and command-line options
|
||||||
| `tty` | Toggle TTY mode
|
| `ml` | Enable/Disable multi-line input mode for complex expressions
|
||||||
| `source <file>` | Execute expressions from a file
|
| `mods` | List all builtin modules (with `*` marking imported ones)
|
||||||
|
| `output [on\|off\|status]` | Enable/Disable printing of expression results
|
||||||
|
| `source <file>` | Load and execute expressions from a file
|
||||||
|
| `tty` | Enable/Disable ANSI terminal output
|
||||||
|===
|
|===
|
||||||
|
|
||||||
== Features
|
== Features
|
||||||
@@ -160,8 +164,16 @@ hello world
|
|||||||
|
|
||||||
[source,bash]
|
[source,bash]
|
||||||
----
|
----
|
||||||
>>> [1, 2, 3, 4, 5] | map(. * 2)
|
>>> it = [1, 2, 3, 4, 5] map $_ * 2
|
||||||
[2, 4, 6, 8, 10]
|
$($([#5]))
|
||||||
|
>>> $$(it)
|
||||||
|
[<
|
||||||
|
2,
|
||||||
|
4,
|
||||||
|
6,
|
||||||
|
8,
|
||||||
|
10
|
||||||
|
>]
|
||||||
----
|
----
|
||||||
|
|
||||||
=== Evaluating from Command Line
|
=== Evaluating from Command Line
|
||||||
@@ -192,7 +204,7 @@ Or from command line:
|
|||||||
|
|
||||||
[source,bash]
|
[source,bash]
|
||||||
----
|
----
|
||||||
./ecli -e '@include "expressions.expr"'
|
./ecli -e "@expressions.expr"
|
||||||
----
|
----
|
||||||
|
|
||||||
== Configuration
|
== Configuration
|
||||||
@@ -233,16 +245,16 @@ The build process generates:
|
|||||||
|
|
||||||
=== Multi-line Input
|
=== Multi-line Input
|
||||||
|
|
||||||
For complex expressions, toggle multi-line mode:
|
For complex expressions, split operations across multiple lines terminating with a backslash (`\`):
|
||||||
|
|
||||||
[source]
|
[source]
|
||||||
----
|
----
|
||||||
>>> multiline
|
>>> ml
|
||||||
>>> result = [1, 2, 3, 4, 5]
|
>>> result = [1, 2, 3, 4, 5] \
|
||||||
... | filter(. > 2)
|
... filter $_ > 2 \
|
||||||
... | map(. * 2)
|
... map $_ * 2
|
||||||
>>> result
|
>>> $$(result)
|
||||||
[6, 8, 10]
|
[<6, 8, 10>
|
||||||
----
|
----
|
||||||
|
|
||||||
=== Script Execution
|
=== Script Execution
|
||||||
@@ -260,16 +272,29 @@ Execute it:
|
|||||||
|
|
||||||
[source,bash]
|
[source,bash]
|
||||||
----
|
----
|
||||||
./ecli -e '@source "calculations.expr"' -e 'result'
|
./ecli -e '@calculations.expr' -e 'result'
|
||||||
|
50
|
||||||
----
|
----
|
||||||
|
|
||||||
=== Chaining Operations
|
=== Other Iterator Examples
|
||||||
|
|
||||||
[source]
|
[source]
|
||||||
----
|
----
|
||||||
>>> data = [{"name": "alice", "age": 30}, {"name": "bob", "age": 25}]
|
>>> data = [{"name": "alice", "age": 30}, {"name": "bob", "age": 25}]
|
||||||
>>> data | map(.name)
|
|
||||||
[alice, bob]
|
// Extract names using map iterator
|
||||||
|
>>> $$(data map ($_).name)
|
||||||
|
[<
|
||||||
|
"alice",
|
||||||
|
"bob"
|
||||||
|
>]
|
||||||
|
|
||||||
|
// Filter ages greater than 28
|
||||||
|
>>> $$(data filter ($_).age > 28 map ($_).name)
|
||||||
|
[<
|
||||||
|
"alice"
|
||||||
|
>]
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
== Troubleshooting
|
== Troubleshooting
|
||||||
|
|||||||
Reference in New Issue
Block a user