@tishlang/tish 1.6.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.toml +2 -0
- package/README.md +2 -0
- package/bin/tish +0 -0
- package/crates/js_to_tish/src/error.rs +2 -8
- package/crates/js_to_tish/src/transform/expr.rs +128 -137
- package/crates/js_to_tish/src/transform/stmt.rs +62 -32
- package/crates/tish/Cargo.toml +15 -5
- package/crates/tish/src/cargo_native_registry.rs +29 -0
- package/crates/tish/src/cli_help.rs +92 -39
- package/crates/tish/src/main.rs +172 -86
- package/crates/tish/src/repl_completion.rs +3 -3
- package/crates/tish/tests/cargo_example_compile.rs +4 -2
- package/crates/tish/tests/integration_test.rs +216 -54
- package/crates/tish/tests/run_optimize_stdout_parity.rs +3 -7
- package/crates/tish/tests/shortcircuit.rs +20 -5
- package/crates/tish_ast/src/ast.rs +92 -23
- package/crates/tish_build_utils/Cargo.toml +4 -0
- package/crates/tish_build_utils/src/lib.rs +136 -8
- package/crates/tish_builtins/Cargo.toml +5 -1
- package/crates/tish_builtins/src/array.rs +65 -33
- package/crates/tish_builtins/src/construct.rs +34 -39
- package/crates/tish_builtins/src/globals.rs +42 -26
- package/crates/tish_builtins/src/helpers.rs +2 -1
- package/crates/tish_builtins/src/lib.rs +5 -5
- package/crates/tish_builtins/src/math.rs +5 -3
- package/crates/tish_builtins/src/object.rs +3 -2
- package/crates/tish_builtins/src/string.rs +144 -22
- package/crates/tish_bytecode/src/chunk.rs +0 -1
- package/crates/tish_bytecode/src/compiler.rs +173 -71
- package/crates/tish_bytecode/src/opcode.rs +24 -6
- package/crates/tish_bytecode/src/peephole.rs +2 -2
- package/crates/tish_compile/Cargo.toml +1 -0
- package/crates/tish_compile/src/codegen.rs +1621 -453
- package/crates/tish_compile/src/infer.rs +75 -19
- package/crates/tish_compile/src/lib.rs +19 -8
- package/crates/tish_compile/src/resolve.rs +278 -137
- package/crates/tish_compile/src/types.rs +184 -24
- package/crates/tish_compile_js/Cargo.toml +1 -0
- package/crates/tish_compile_js/src/codegen.rs +181 -37
- package/crates/tish_compile_js/src/lib.rs +3 -1
- package/crates/tish_compile_js/src/tests_jsx.rs +30 -6
- package/crates/tish_compiler_wasm/src/lib.rs +16 -13
- package/crates/tish_compiler_wasm/src/resolve_virtual.rs +69 -59
- package/crates/tish_core/Cargo.toml +8 -0
- package/crates/tish_core/src/json.rs +107 -56
- package/crates/tish_core/src/lib.rs +4 -2
- package/crates/tish_core/src/macros.rs +5 -5
- package/crates/tish_core/src/uri.rs +9 -6
- package/crates/tish_core/src/value.rs +145 -43
- package/crates/tish_core/src/vmref.rs +178 -0
- package/crates/tish_cranelift/src/link.rs +6 -9
- package/crates/tish_cranelift/src/lower.rs +14 -8
- package/crates/tish_eval/Cargo.toml +17 -2
- package/crates/tish_eval/src/eval.rs +474 -165
- package/crates/tish_eval/src/http.rs +61 -0
- package/crates/tish_eval/src/lib.rs +12 -8
- package/crates/tish_eval/src/natives.rs +136 -38
- package/crates/tish_eval/src/promise.rs +14 -8
- package/crates/tish_eval/src/timers.rs +28 -19
- package/crates/tish_eval/src/value.rs +17 -6
- package/crates/tish_eval/src/value_convert.rs +13 -5
- package/crates/tish_fmt/src/lib.rs +149 -43
- package/crates/tish_lexer/src/lib.rs +232 -63
- package/crates/tish_lexer/src/token.rs +10 -6
- package/crates/tish_llvm/src/lib.rs +17 -8
- package/crates/tish_lsp/Cargo.toml +4 -1
- package/crates/tish_lsp/README.md +1 -1
- package/crates/tish_lsp/src/builtin_goto.rs +261 -0
- package/crates/tish_lsp/src/import_goto.rs +549 -0
- package/crates/tish_lsp/src/main.rs +504 -106
- package/crates/tish_native/src/build.rs +4 -8
- package/crates/tish_native/src/lib.rs +54 -21
- package/crates/tish_opt/src/lib.rs +84 -52
- package/crates/tish_parser/src/lib.rs +45 -13
- package/crates/tish_parser/src/parser.rs +505 -130
- package/crates/tish_resolve/Cargo.toml +13 -0
- package/crates/tish_resolve/src/lib.rs +3436 -0
- package/crates/tish_resolve/src/pos.rs +133 -0
- package/crates/tish_runtime/Cargo.toml +68 -3
- package/crates/tish_runtime/src/http.rs +1136 -145
- package/crates/tish_runtime/src/http_fetch.rs +38 -27
- package/crates/tish_runtime/src/http_hyper.rs +418 -0
- package/crates/tish_runtime/src/http_prefork.rs +189 -0
- package/crates/tish_runtime/src/lib.rs +375 -189
- package/crates/tish_runtime/src/promise.rs +199 -40
- package/crates/tish_runtime/src/promise_io.rs +2 -1
- package/crates/tish_runtime/src/timers.rs +37 -1
- package/crates/tish_runtime/src/ws.rs +65 -42
- package/crates/tish_runtime/tests/fetch_readable_stream.rs +5 -4
- package/crates/tish_ui/src/jsx.rs +317 -27
- package/crates/tish_ui/src/lib.rs +5 -2
- package/crates/tish_ui/src/runtime/hooks.rs +406 -45
- package/crates/tish_ui/src/runtime/mod.rs +36 -9
- package/crates/tish_vm/Cargo.toml +15 -5
- package/crates/tish_vm/src/vm.rs +725 -281
- package/crates/tish_vm/tests/peephole_jump_chain_logical_or.rs +11 -4
- package/crates/tish_wasm/src/lib.rs +55 -42
- package/crates/tish_wasm_runtime/Cargo.toml +2 -1
- package/crates/tish_wasm_runtime/src/lib.rs +1 -1
- package/crates/tishlang_cargo_bindgen/Cargo.toml +26 -0
- package/crates/tishlang_cargo_bindgen/src/classify.rs +265 -0
- package/crates/tishlang_cargo_bindgen/src/discover.rs +120 -0
- package/crates/tishlang_cargo_bindgen/src/infer.rs +372 -0
- package/crates/tishlang_cargo_bindgen/src/lib.rs +350 -0
- package/crates/tishlang_cargo_bindgen/src/main.rs +164 -0
- package/crates/tishlang_cargo_bindgen/src/metadata.rs +114 -0
- package/justfile +8 -0
- package/package.json +1 -1
- package/platform/darwin-arm64/tish +0 -0
- package/platform/darwin-x64/tish +0 -0
- package/platform/linux-arm64/tish +0 -0
- package/platform/linux-x64/tish +0 -0
- package/platform/win32-x64/tish.exe +0 -0
package/crates/tish/Cargo.toml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "tishlang"
|
|
3
|
-
version = "1.
|
|
3
|
+
version = "1.8.0"
|
|
4
4
|
edition = "2021"
|
|
5
5
|
description = "Tish CLI - run, REPL, compile to native"
|
|
6
6
|
license-file = { workspace = true }
|
|
@@ -11,12 +11,21 @@ name = "tish"
|
|
|
11
11
|
path = "src/main.rs"
|
|
12
12
|
|
|
13
13
|
[features]
|
|
14
|
-
#
|
|
15
|
-
default
|
|
16
|
-
#
|
|
17
|
-
|
|
14
|
+
# The published `tish` CLI always includes every optional runtime (http, timers, fs, process, regex, ws).
|
|
15
|
+
# Use `cargo build -p tishlang --no-default-features` when you need a locked-down toolchain
|
|
16
|
+
# (see workspace `justfile`). `tish run --feature …` / `tish build --feature …` gate what runs
|
|
17
|
+
# or what gets linked into a *native output* binary — they are not the primary way to ship a
|
|
18
|
+
# “full” vs “empty” CLI.
|
|
19
|
+
default = ["full"]
|
|
20
|
+
# Alias: same dependency edges as `default` (kept for `--features full` in CI and docs).
|
|
21
|
+
# Includes `pg` so `tish run` can resolve `import … from 'tish-pg'` (`cargo:tish_pg`) on the bytecode VM.
|
|
22
|
+
# Requires `tish-pg` next to this workspace root (`…/tish/tish-pg`); CI runs `scripts/ci/ensure-tish-pg.sh`.
|
|
23
|
+
full = ["http", "fs", "process", "regex", "ws", "timers", "pg"]
|
|
24
|
+
# Opt-out: build without Postgres (`cargo build -p tishlang --no-default-features --features http,...`).
|
|
25
|
+
pg = ["dep:tish_pg"]
|
|
18
26
|
# Individual capability flags
|
|
19
27
|
http = ["tishlang_eval/http", "tishlang_runtime/http", "tishlang_compile/http", "tishlang_vm/http"]
|
|
28
|
+
timers = ["tishlang_eval/timers", "tishlang_compile/timers", "tishlang_vm/timers"]
|
|
20
29
|
fs = ["tishlang_eval/fs", "tishlang_runtime/fs", "tishlang_compile/fs", "tishlang_vm/fs"]
|
|
21
30
|
process = ["tishlang_eval/process", "tishlang_runtime/process", "tishlang_compile/process", "tishlang_vm/process"]
|
|
22
31
|
regex = ["tishlang_eval/regex", "tishlang_runtime/regex", "tishlang_compile/regex", "tishlang_vm/regex"]
|
|
@@ -40,6 +49,7 @@ tishlang_runtime = { path = "../tish_runtime", version = ">=0.1" }
|
|
|
40
49
|
tishlang_core = { path = "../tish_core", version = ">=0.1" }
|
|
41
50
|
tishlang_js_to_tish = { path = "../js_to_tish", version = ">=0.1" }
|
|
42
51
|
clap = { version = "4.6.0", features = ["derive", "color"] }
|
|
52
|
+
tish_pg = { path = "../../../tish-pg", package = "tish-pg", optional = true }
|
|
43
53
|
|
|
44
54
|
[dev-dependencies]
|
|
45
55
|
rayon = "1.11"
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//! Registers `cargo:*` Rust shims on the bytecode VM (`tish run`, REPL).
|
|
2
|
+
//!
|
|
3
|
+
//! Native `tish build` outputs register their own crates at link time; the
|
|
4
|
+
//! interpreter path must populate [`tishlang_vm::Vm::register_native_module`].
|
|
5
|
+
|
|
6
|
+
#[cfg(feature = "pg")]
|
|
7
|
+
pub(crate) fn register_bytecode_native_modules(vm: &mut tishlang_vm::Vm) {
|
|
8
|
+
use std::sync::Arc;
|
|
9
|
+
use tishlang_core::{ObjectMap, Value};
|
|
10
|
+
|
|
11
|
+
let mut om = ObjectMap::with_capacity(8);
|
|
12
|
+
om.insert(
|
|
13
|
+
Arc::from("per_worker_client"),
|
|
14
|
+
Value::native(tish_pg::per_worker_client),
|
|
15
|
+
);
|
|
16
|
+
om.insert(Arc::from("connect"), Value::native(tish_pg::connect));
|
|
17
|
+
om.insert(Arc::from("prepare"), Value::native(tish_pg::prepare));
|
|
18
|
+
om.insert(
|
|
19
|
+
Arc::from("query_prepared"),
|
|
20
|
+
Value::native(tish_pg::query_prepared),
|
|
21
|
+
);
|
|
22
|
+
om.insert(Arc::from("query_all"), Value::native(tish_pg::query_all));
|
|
23
|
+
om.insert(Arc::from("migrate"), Value::native(tish_pg::migrate));
|
|
24
|
+
om.insert(Arc::from("close"), Value::native(tish_pg::close));
|
|
25
|
+
vm.register_native_module("cargo:tish_pg", om);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
#[cfg(not(feature = "pg"))]
|
|
29
|
+
pub(crate) fn register_bytecode_native_modules(_vm: &mut tishlang_vm::Vm) {}
|
|
@@ -9,7 +9,7 @@ use clap::{CommandFactory, Parser, Subcommand};
|
|
|
9
9
|
|
|
10
10
|
/// FIGlet-style block letters (UTF-8). On a TTY, a short expand + palette-color animation runs.
|
|
11
11
|
const TISH_BANNER_LINES: &[&str] = &[
|
|
12
|
-
|
|
12
|
+
"",
|
|
13
13
|
"████████╗██╗███████╗██╗ ██╗",
|
|
14
14
|
"╚══██╔══╝██║██╔════╝██║ ██║",
|
|
15
15
|
" ██║ ██║███████╗███████║",
|
|
@@ -26,13 +26,13 @@ const BANNER_FRAME_MS: u64 = 20;
|
|
|
26
26
|
|
|
27
27
|
/// Orange → Yellow → Green → Teal → Blue → Purple → Pink (matching the brand palette).
|
|
28
28
|
const PALETTE: &[(u8, u8, u8)] = &[
|
|
29
|
-
(255, 159,
|
|
30
|
-
(255, 213,
|
|
31
|
-
(
|
|
32
|
-
(
|
|
33
|
-
(
|
|
34
|
-
(175,
|
|
35
|
-
(255,
|
|
29
|
+
(255, 159, 64), // Orange
|
|
30
|
+
(255, 213, 64), // Yellow
|
|
31
|
+
(52, 199, 89), // Green
|
|
32
|
+
(48, 209, 188), // Teal
|
|
33
|
+
(10, 132, 255), // Blue
|
|
34
|
+
(175, 82, 222), // Purple
|
|
35
|
+
(255, 55, 148), // Pink
|
|
36
36
|
];
|
|
37
37
|
|
|
38
38
|
fn ease_out_cubic(t: f32) -> f32 {
|
|
@@ -128,8 +128,8 @@ pub fn print_tish_banner() {
|
|
|
128
128
|
pub fn build_command() -> clap::Command {
|
|
129
129
|
Cli::command()
|
|
130
130
|
.after_help(cli_after_help())
|
|
131
|
-
.mut_subcommand("run",
|
|
132
|
-
.mut_subcommand("repl",
|
|
131
|
+
.mut_subcommand("run", |sub| sub.after_help(run_after_help()))
|
|
132
|
+
.mut_subcommand("repl", |sub| sub.after_help(repl_after_help()))
|
|
133
133
|
.mut_subcommand("build", |sub| sub.after_long_help(build_after_help()))
|
|
134
134
|
}
|
|
135
135
|
|
|
@@ -138,7 +138,10 @@ fn count_help_lines(cmd: &mut clap::Command, sub_name: Option<&str>) -> usize {
|
|
|
138
138
|
let mut buf = Vec::<u8>::new();
|
|
139
139
|
if let Some(name) = sub_name {
|
|
140
140
|
if cmd.find_subcommand(name).is_some() {
|
|
141
|
-
let _ = cmd
|
|
141
|
+
let _ = cmd
|
|
142
|
+
.find_subcommand_mut(name)
|
|
143
|
+
.unwrap()
|
|
144
|
+
.write_long_help(&mut buf);
|
|
142
145
|
} else {
|
|
143
146
|
let _ = cmd.write_long_help(&mut buf);
|
|
144
147
|
}
|
|
@@ -236,8 +239,11 @@ pub fn print_banner_with_help(argv: &[String]) {
|
|
|
236
239
|
let mut out = io::stdout().lock();
|
|
237
240
|
write_tish_banner_frame(&mut out, 1.0, 0);
|
|
238
241
|
let _ = writeln!(out); // blank separator (row n+1)
|
|
239
|
-
|
|
240
|
-
let _ = writeln!(
|
|
242
|
+
// ── Manual prefix (MAIN_PREFIX_LINES = 4 lines) ──────────────────
|
|
243
|
+
let _ = writeln!(
|
|
244
|
+
out,
|
|
245
|
+
"{H_PURPLE}Tish{H_RESET} {H_GREY}(version {VERSION}){H_RESET}"
|
|
246
|
+
);
|
|
241
247
|
let _ = writeln!(out, "Minimal TS/JS-ish language");
|
|
242
248
|
let _ = writeln!(out, "{H_PINK}https://tishlang.com{H_RESET}");
|
|
243
249
|
let _ = writeln!(out); // blank before Usage
|
|
@@ -289,20 +295,24 @@ fn rgb_bold(r: u8, g: u8, b: u8) -> Style {
|
|
|
289
295
|
/// Orange → section headers / usage. Teal → literals (commands, flags). Yellow → placeholders.
|
|
290
296
|
pub fn cargo_help_styles() -> Styles {
|
|
291
297
|
Styles::styled()
|
|
292
|
-
.header(rgb_bold(255, 159,
|
|
293
|
-
.usage(rgb_bold(255, 159,
|
|
294
|
-
.literal(rgb_bold(
|
|
295
|
-
.placeholder(rgb_bold(255, 213,
|
|
296
|
-
.error(rgb_bold(255,
|
|
297
|
-
.valid(rgb_bold(
|
|
298
|
-
.invalid(rgb_bold(255,
|
|
298
|
+
.header(rgb_bold(255, 159, 64)) // Orange – "Commands:", "Options:", "Usage:"
|
|
299
|
+
.usage(rgb_bold(255, 159, 64)) // Orange
|
|
300
|
+
.literal(rgb_bold(48, 209, 188)) // Teal – run, repl, --help, -V …
|
|
301
|
+
.placeholder(rgb_bold(255, 213, 64)) // Yellow – <FILE>, <NAME>, …
|
|
302
|
+
.error(rgb_bold(255, 55, 148)) // Pink – error messages
|
|
303
|
+
.valid(rgb_bold(52, 199, 89)) // Green – valid values
|
|
304
|
+
.invalid(rgb_bold(255, 55, 148)) // Pink – invalid values
|
|
299
305
|
}
|
|
300
306
|
|
|
301
307
|
/// Returns the colored `after_help` text for the top-level `tish --help`.
|
|
302
308
|
/// Colors are emitted only when stdout is a TTY.
|
|
303
309
|
pub fn cli_after_help() -> String {
|
|
304
310
|
let (oh, t, r) = if io::stdout().is_terminal() {
|
|
305
|
-
(
|
|
311
|
+
(
|
|
312
|
+
"\x1b[1;38;2;255;159;64m",
|
|
313
|
+
"\x1b[1;38;2;48;209;188m",
|
|
314
|
+
"\x1b[0m",
|
|
315
|
+
)
|
|
306
316
|
} else {
|
|
307
317
|
("", "", "")
|
|
308
318
|
};
|
|
@@ -327,7 +337,9 @@ fn capabilities_section(oh: &str, t: &str, r: &str) -> String {
|
|
|
327
337
|
|
|
328
338
|
{oh}Capabilities{r} (--feature, repeatable; comma-separated values are split):
|
|
329
339
|
{t}http{r}
|
|
330
|
-
Network: fetch, serve, Promise
|
|
340
|
+
Network: fetch, fetchAll, serve, Promise (and `await`); enabling http also enables timers
|
|
341
|
+
{t}timers{r}
|
|
342
|
+
setTimeout, setInterval, clearTimeout, clearInterval (global + `import from \"timers\"` / tish:timers)
|
|
331
343
|
{t}fs{r}
|
|
332
344
|
Filesystem: readFile, writeFile, fileExists, isDir, readDir, mkdir
|
|
333
345
|
{t}process{r}
|
|
@@ -337,16 +349,20 @@ fn capabilities_section(oh: &str, t: &str, r: &str) -> String {
|
|
|
337
349
|
{t}ws{r}
|
|
338
350
|
WebSocket client / server
|
|
339
351
|
{t}full{r}
|
|
340
|
-
All of the above (http, fs, process, regex, ws)
|
|
352
|
+
All of the above (http, timers, fs, process, regex, ws)
|
|
341
353
|
|
|
342
|
-
Omit --feature to
|
|
354
|
+
Omit --feature to allow every capability compiled into this `tish` binary; pass flags to restrict what scripts may use. The CLI is normally built with all of them (Cargo default on `tishlang`)."
|
|
343
355
|
)
|
|
344
356
|
}
|
|
345
357
|
|
|
346
358
|
/// Returns the colored `after_help` for `tish run --help`.
|
|
347
359
|
pub fn run_after_help() -> String {
|
|
348
360
|
let (oh, t, r) = if io::stdout().is_terminal() {
|
|
349
|
-
(
|
|
361
|
+
(
|
|
362
|
+
"\x1b[1;38;2;255;159;64m",
|
|
363
|
+
"\x1b[1;38;2;48;209;188m",
|
|
364
|
+
"\x1b[0m",
|
|
365
|
+
)
|
|
350
366
|
} else {
|
|
351
367
|
("", "", "")
|
|
352
368
|
};
|
|
@@ -356,7 +372,11 @@ pub fn run_after_help() -> String {
|
|
|
356
372
|
/// Returns the colored `after_help` for `tish repl --help`.
|
|
357
373
|
pub fn repl_after_help() -> String {
|
|
358
374
|
let (oh, t, r) = if io::stdout().is_terminal() {
|
|
359
|
-
(
|
|
375
|
+
(
|
|
376
|
+
"\x1b[1;38;2;255;159;64m",
|
|
377
|
+
"\x1b[1;38;2;48;209;188m",
|
|
378
|
+
"\x1b[0m",
|
|
379
|
+
)
|
|
360
380
|
} else {
|
|
361
381
|
("", "", "")
|
|
362
382
|
};
|
|
@@ -366,7 +386,11 @@ pub fn repl_after_help() -> String {
|
|
|
366
386
|
/// Returns the colored `after_long_help` for `tish build --help`.
|
|
367
387
|
pub fn build_after_help() -> String {
|
|
368
388
|
let (oh, t, r) = if io::stdout().is_terminal() {
|
|
369
|
-
(
|
|
389
|
+
(
|
|
390
|
+
"\x1b[1;38;2;255;159;64m",
|
|
391
|
+
"\x1b[1;38;2;48;209;188m",
|
|
392
|
+
"\x1b[0m",
|
|
393
|
+
)
|
|
370
394
|
} else {
|
|
371
395
|
("", "", "")
|
|
372
396
|
};
|
|
@@ -392,7 +416,9 @@ pub fn build_after_help() -> String {
|
|
|
392
416
|
|
|
393
417
|
{oh}Capabilities{r} (--feature, repeatable; comma-separated values are split):
|
|
394
418
|
{t}http{r}
|
|
395
|
-
Network: fetch, serve, Promise
|
|
419
|
+
Network: fetch, fetchAll, serve, Promise (and `await`); enabling http also enables timers
|
|
420
|
+
{t}timers{r}
|
|
421
|
+
setTimeout, setInterval, clearTimeout, clearInterval (global + `import from \"timers\"` / tish:timers)
|
|
396
422
|
{t}fs{r}
|
|
397
423
|
Filesystem: readFile, writeFile, fileExists, isDir, readDir, mkdir
|
|
398
424
|
{t}process{r}
|
|
@@ -402,10 +428,9 @@ pub fn build_after_help() -> String {
|
|
|
402
428
|
{t}ws{r}
|
|
403
429
|
WebSocket client / server
|
|
404
430
|
{t}full{r}
|
|
405
|
-
All of the above (http, fs, process, regex, ws)
|
|
431
|
+
All of the above (http, timers, fs, process, regex, ws)
|
|
406
432
|
|
|
407
|
-
|
|
408
|
-
Build `tish` with matching Cargo features (e.g. cargo build -p tishlang --features full)."
|
|
433
|
+
For `--target native`, these choose what is linked into the **output** executable (omit = same set as this `tish` binary was built with). Minimal native outputs still use a full `tish` CLI unless you built it with `cargo build -p tishlang --no-default-features`."
|
|
409
434
|
)
|
|
410
435
|
}
|
|
411
436
|
|
|
@@ -421,12 +446,22 @@ pub(crate) struct Cli {
|
|
|
421
446
|
#[derive(Parser)]
|
|
422
447
|
pub(crate) struct RunArgs {
|
|
423
448
|
/// Path to a `.tish` file, or `-` to read the program from stdin (like `node -`).
|
|
424
|
-
#[arg(
|
|
449
|
+
#[arg(
|
|
450
|
+
required = true,
|
|
451
|
+
allow_hyphen_values = true,
|
|
452
|
+
value_name = "FILE",
|
|
453
|
+
help_heading = "Arguments"
|
|
454
|
+
)]
|
|
425
455
|
pub file: String,
|
|
426
456
|
/// `vm` or `interp` (see `tish --help` for capabilities / `--feature`).
|
|
427
|
-
#[arg(
|
|
457
|
+
#[arg(
|
|
458
|
+
long,
|
|
459
|
+
default_value = "vm",
|
|
460
|
+
value_name = "NAME",
|
|
461
|
+
help_heading = "Options"
|
|
462
|
+
)]
|
|
428
463
|
pub backend: String,
|
|
429
|
-
///
|
|
464
|
+
/// Restrict which platform APIs the script may use (omit = all capabilities compiled into this `tish`).
|
|
430
465
|
#[arg(
|
|
431
466
|
long = "feature",
|
|
432
467
|
value_name = "NAME",
|
|
@@ -442,9 +477,14 @@ pub(crate) struct RunArgs {
|
|
|
442
477
|
#[derive(Parser)]
|
|
443
478
|
pub(crate) struct ReplArgs {
|
|
444
479
|
/// `vm` or `interp` (see `tish --help`).
|
|
445
|
-
#[arg(
|
|
480
|
+
#[arg(
|
|
481
|
+
long,
|
|
482
|
+
default_value = "vm",
|
|
483
|
+
value_name = "NAME",
|
|
484
|
+
help_heading = "Options"
|
|
485
|
+
)]
|
|
446
486
|
pub backend: String,
|
|
447
|
-
///
|
|
487
|
+
/// Restrict which platform APIs the REPL may use (omit = all capabilities compiled into this `tish`).
|
|
448
488
|
#[arg(
|
|
449
489
|
long = "feature",
|
|
450
490
|
value_name = "NAME",
|
|
@@ -467,12 +507,22 @@ pub(crate) struct BuildArgs {
|
|
|
467
507
|
)]
|
|
468
508
|
pub output: String,
|
|
469
509
|
/// `native`, `js`, `wasm`, or `wasi` (see long help below).
|
|
470
|
-
#[arg(
|
|
510
|
+
#[arg(
|
|
511
|
+
long,
|
|
512
|
+
default_value = "native",
|
|
513
|
+
value_name = "TARGET",
|
|
514
|
+
help_heading = "Options"
|
|
515
|
+
)]
|
|
471
516
|
pub target: String,
|
|
472
517
|
/// `rust`, `cranelift`, or `llvm` (only for `--target native`).
|
|
473
|
-
#[arg(
|
|
518
|
+
#[arg(
|
|
519
|
+
long,
|
|
520
|
+
default_value = "rust",
|
|
521
|
+
value_name = "BACKEND",
|
|
522
|
+
help_heading = "Options"
|
|
523
|
+
)]
|
|
474
524
|
pub native_backend: String,
|
|
475
|
-
///
|
|
525
|
+
/// For `--target native`: which capabilities to link into the produced binary (omit = same as this `tish`; see long help).
|
|
476
526
|
#[arg(
|
|
477
527
|
long = "feature",
|
|
478
528
|
value_name = "NAME",
|
|
@@ -482,6 +532,9 @@ pub(crate) struct BuildArgs {
|
|
|
482
532
|
pub features: Vec<String>,
|
|
483
533
|
#[arg(long, help_heading = "Options")]
|
|
484
534
|
pub no_optimize: bool,
|
|
535
|
+
/// For `--target js` project builds: emit `OUTPUT.js.map` and `//# sourceMappingURL=…` so JS/TS tools can jump to original `.tish` (implies `--no-optimize` for that build).
|
|
536
|
+
#[arg(long, help_heading = "Options")]
|
|
537
|
+
pub source_map: bool,
|
|
485
538
|
/// Entry `.tish` file (or `.js` where supported).
|
|
486
539
|
#[arg(required = true, value_name = "FILE", help_heading = "Arguments")]
|
|
487
540
|
pub file: String,
|