1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//! Command-line interface for the `node` binary.
use clap::Parser;
#[derive(Parser, Debug)]
#[command(
name = "node",
version,
about = "JavaScript on fusevm — a compiled JS runtime (bytecode VM + Cranelift JIT)",
long_about = None,
)]
pub struct Cli {
/// Evaluate a one-liner instead of a file (`node -e 'console.log(1+1)'`).
#[arg(short = 'e', long = "eval", value_name = "SRC")]
pub eval: Option<String>,
/// Start the interactive REPL.
#[arg(long = "repl")]
pub repl: bool,
/// Speak the Language Server Protocol over stdio.
#[arg(long = "lsp")]
pub lsp: bool,
/// Speak the Debug Adapter Protocol over stdio.
#[arg(long = "dap")]
pub dap: bool,
/// Ahead-of-time compile the script to a standalone native executable.
#[arg(long = "build")]
pub build: bool,
/// Print the compiled fusevm bytecode for the script and exit.
#[arg(long = "dump-bytecode")]
pub dump_bytecode: bool,
/// Print the lexer token stream for the script and exit.
#[arg(long = "dump-tokens")]
pub dump_tokens: bool,
/// Print the parsed AST for the script and exit.
#[arg(long = "dump-ast")]
pub dump_ast: bool,
/// Print a fusevm bytecode disassembly listing for the script and exit.
#[arg(long = "disasm")]
pub disasm: bool,
/// Run the script, then report which fusevm tiers took each of its chunks.
#[arg(long = "tiers")]
pub tiers: bool,
/// The `.js` script to run (omit with --repl / --lsp / --dap / -e).
#[arg(value_name = "FILE")]
pub file: Option<String>,
/// Arguments passed through to the JS program.
#[arg(trailing_var_arg = true, allow_hyphen_values = true)]
pub argv: Vec<String>,
}
/// Parse the process arguments.
pub fn parse() -> Cli {
Cli::parse()
}