Skip to main content

nodejs/
cli.rs

1//! Command-line interface for the `node` binary.
2
3use clap::Parser;
4
5#[derive(Parser, Debug)]
6#[command(
7    name = "node",
8    version,
9    about = "JavaScript on fusevm — a compiled JS runtime (bytecode VM + Cranelift JIT)",
10    long_about = None,
11)]
12pub struct Cli {
13    /// Evaluate a one-liner instead of a file (`node -e 'console.log(1+1)'`).
14    #[arg(short = 'e', long = "eval", value_name = "SRC")]
15    pub eval: Option<String>,
16
17    /// The `.js` script to run (omit with -e or to read stdin).
18    #[arg(value_name = "FILE")]
19    pub file: Option<String>,
20
21    /// Arguments passed through to the JS program.
22    #[arg(trailing_var_arg = true, allow_hyphen_values = true)]
23    pub argv: Vec<String>,
24}
25
26/// Parse the process arguments.
27pub fn parse() -> Cli {
28    Cli::parse()
29}