ecli.doc: correction and improvement

This commit is contained in:
2026-06-06 06:14:58 +02:00
parent 6a6c897268
commit dba8e01aa0
+44 -19
View File
@@ -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:
- Interactive expression testing and prototyping
- Command history survival across sessions
- Batch expression evaluation from scripts
- Data processing and transformation
- Mathematical computations with fractions and complex operators
@@ -61,7 +62,7 @@ Start the interactive REPL:
./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
@@ -89,11 +90,14 @@ Within the REPL, you can use the following commands:
|===
| 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
| `multiline` | Toggle multi-line input mode for complex expressions
| `tty` | Toggle TTY mode
| `source <file>` | Execute expressions from a file
| `help` | Display available commands and command-line options
| `ml` | Enable/Disable multi-line input mode for complex expressions
| `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
@@ -160,8 +164,16 @@ hello world
[source,bash]
----
>>> [1, 2, 3, 4, 5] | map(. * 2)
[2, 4, 6, 8, 10]
>>> it = [1, 2, 3, 4, 5] map $_ * 2
$($([#5]))
>>> $$(it)
[<
2,
4,
6,
8,
10
>]
----
=== Evaluating from Command Line
@@ -192,7 +204,7 @@ Or from command line:
[source,bash]
----
./ecli -e '@include "expressions.expr"'
./ecli -e "@expressions.expr"
----
== Configuration
@@ -233,16 +245,16 @@ The build process generates:
=== Multi-line Input
For complex expressions, toggle multi-line mode:
For complex expressions, split operations across multiple lines terminating with a backslash (`\`):
[source]
----
>>> multiline
>>> result = [1, 2, 3, 4, 5]
... | filter(. > 2)
... | map(. * 2)
>>> result
[6, 8, 10]
>>> ml
>>> result = [1, 2, 3, 4, 5] \
... filter $_ > 2 \
... map $_ * 2
>>> $$(result)
[<6, 8, 10>
----
=== Script Execution
@@ -260,16 +272,29 @@ Execute it:
[source,bash]
----
./ecli -e '@source "calculations.expr"' -e 'result'
./ecli -e '@calculations.expr' -e 'result'
50
----
=== Chaining Operations
=== Other Iterator Examples
[source]
----
>>> 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