mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 09:28:13 +00:00
js: Add a command line argument to evaluate a string as a script
For example: $ js -c "console.log(42)" 42
This commit is contained in:
parent
65de0d2910
commit
19d4f52a9e
2 changed files with 32 additions and 13 deletions
|
@ -28,18 +28,26 @@ Run `help()` in REPL mode to see its available built-in functions.
|
|||
* `-m`, `--as-module`: Treat as module
|
||||
* `-l`, `--print-last-result`: Print the result of the last statement executed.
|
||||
* `-g`, `--gc-on-every-allocation`: Run garbage collection on every allocation.
|
||||
* `-c`, `--disable-ansi-colors`: Disable ANSI colors
|
||||
* `-i`, `--disable-ansi-colors`: Disable ANSI colors
|
||||
* `-h`, `--disable-source-location-hints`: Disable source location hints
|
||||
* `-s`, `--no-syntax-highlight`: Disable live syntax highlighting in the REPL
|
||||
* `-c`, `--evaluate`: Evaluate the argument as a script
|
||||
|
||||
## Examples
|
||||
|
||||
Here's how you execute a script:
|
||||
Here's how you execute a script from a file:
|
||||
|
||||
```sh
|
||||
$ js ~/Source/js/type-play.js
|
||||
```
|
||||
|
||||
Here's how you execute a script as a command line argument:
|
||||
|
||||
```sh
|
||||
$ js -c "console.log(42)"
|
||||
42
|
||||
```
|
||||
|
||||
And here's an example of an interactive REPL session:
|
||||
|
||||
```js
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue