char/avril
(wip) why'd you have to go and make things so complicaaaaated?
git clone https://git.t4t.associates/char/avril
b862289
main
Script arguments
process.args from avril:std is a frozen array of strings containing the
arguments supplied to the script. It excludes the executable, command, runtime
options, and entry module. Reading it requires no capability.
import { process } from "avril:std" ; console . log ( process . args );
avril run-0 main.ts hello--verbose # ["hello", "--verbose"]
For run and serve, everything after the entry module is a script argument.
Put all avril options before the module. Flags such as --help, -0,
--env-file, and --allow-read after the module are passed through unchanged;
they cannot affect runtime configuration or permissions.
avril run--help # avril's help avril run main.ts--help # script receives ["--help"] avril run main.ts-- --help # script receives ["--", "--help"] avril run-- --help # runs a file named --help, with no arguments avril serve--port=8000 app.ts--debug # app.ts receives ["--debug"]
An optional -- before the entry module ends avril option parsing and is not
included in process.args. A -- after the module is an ordinary script
argument. Empty strings, whitespace, Unicode, and repeated arguments are
preserved as received from the shell. CLI arguments must be valid UTF-8.
The array has stable identity within an isolate and cannot be mutated or replaced. Workers, including nested workers, inherit the same argument values in their own frozen arrays. With no script arguments, the array is empty.
REPL and tests
For REPL and test sessions, the first -- separates runtime options and test
targets from script arguments. That separator is omitted; everything after it
is passed through unchanged, including further -- tokens.
avril repl-0 -- hello--help avril -0 -- hello--help # the default REPL avril test tests/-- hello--help avril test-- hello--help # default test discovery # process.args is ["hello", "--help"] in each case
Without --, REPL and test sessions have an empty argument array. Test targets
and runner options stay before the separator; options may still follow test
targets there. Use ./-example_test.ts to select a dash-prefixed filename.
Arguments are available during test-file evaluation, including --no-run,
and every test-file isolate and its workers receive the same values.
1# Script arguments 2 3`process.args` from `avril:std` is a frozen array of strings containing the 4arguments supplied to the script. It excludes the executable, command, runtime 5options, and entry module. Reading it requires no capability. 6 7``` ts 8import { process } from "avril:std"; 9 10console.log(process.args); 11``` 12 13``` sh 14avril run -0 main.ts hello --verbose 15# ["hello", "--verbose"] 16``` 17 18For `run` and `serve`, **everything after the entry module is a script argument**. 19Put all avril options before the module. Flags such as `--help`, `-0`, 20`--env-file`, and `--allow-read` after the module are passed through unchanged; 21they cannot affect runtime configuration or permissions. 22 23``` sh 24avril run --help # avril's help 25avril run main.ts --help # script receives ["--help"] 26avril run main.ts -- --help # script receives ["--", "--help"] 27avril run -- --help # runs a file named --help, with no arguments 28avril serve --port=8000 app.ts --debug 29# app.ts receives ["--debug"] 30``` 31 32An optional `--` before the entry module ends avril option parsing and is not 33included in `process.args`. A `--` after the module is an ordinary script 34argument. Empty strings, whitespace, Unicode, and repeated arguments are 35preserved as received from the shell. CLI arguments must be valid UTF-8. 36 37The array has stable identity within an isolate and cannot be mutated or 38replaced. Workers, including nested workers, inherit the same argument values 39in their own frozen arrays. With no script arguments, the array is empty. 40 41## REPL and tests 42 43For REPL and test sessions, the first `--` separates runtime options and test 44targets from script arguments. That separator is omitted; everything after it 45is passed through unchanged, including further `--` tokens. 46 47``` sh 48avril repl -0 -- hello --help 49avril -0 -- hello --help # the default REPL 50avril test tests/ -- hello --help 51avril test -- hello --help # default test discovery 52# process.args is ["hello", "--help"] in each case 53``` 54 55Without `--`, REPL and test sessions have an empty argument array. Test targets 56and runner options stay before the separator; options may still follow test 57targets there. Use `./-example_test.ts` to select a dash-prefixed filename. 58Arguments are available during test-file evaluation, including `--no-run`, 59and every test-file isolate and its workers receive the same values.