Browse Source

Upgrade clap to 4.0, add value hints for zsh and fish (#2336)

This Pull Request fixes/closes #2330.

It changes the following:

- Upgrades from clap 3 to clap 4 (note that criterion still uses clap 3, tracked here: https://github.com/bheisler/criterion.rs/issues/596)
- Updates the derive syntax with the new 4.0 syntax
- Adds hints for fish & zsh


Co-authored-by: José Julián Espina <jedel0124@gmail.com>
pull/2347/head
Iban Eguia 2 years ago
parent
commit
9998a6787c
  1. 35
      Cargo.lock
  2. 2
      boa_cli/Cargo.toml
  3. 20
      boa_cli/src/main.rs
  4. 2
      boa_tester/Cargo.toml
  5. 21
      boa_tester/src/main.rs

35
Cargo.lock generated

@ -61,7 +61,7 @@ version = "0.16.0"
dependencies = [
"boa_engine",
"boa_interner",
"clap",
"clap 4.0.12",
"colored",
"jemallocator",
"phf",
@ -167,7 +167,7 @@ dependencies = [
"boa_engine",
"boa_gc",
"boa_interner",
"clap",
"clap 4.0.12",
"colored",
"fxhash",
"gc",
@ -272,23 +272,33 @@ name = "clap"
version = "3.2.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86447ad904c7fb335a790c9d7fe3d0d971dc523b8ccd1561a520de9a85302750"
dependencies = [
"bitflags",
"clap_lex 0.2.4",
"indexmap",
"textwrap",
]
[[package]]
name = "clap"
version = "4.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "385007cbbed899260395a4107435fead4cad80684461b3cc78238bdcb0bad58f"
dependencies = [
"atty",
"bitflags",
"clap_derive",
"clap_lex",
"indexmap",
"clap_lex 0.3.0",
"once_cell",
"strsim",
"termcolor",
"textwrap",
]
[[package]]
name = "clap_derive"
version = "3.2.18"
version = "4.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65"
checksum = "db342ce9fda24fb191e2ed4e102055a4d381c1086a06630174cd8da8d5d917ce"
dependencies = [
"heck",
"proc-macro-error",
@ -306,6 +316,15 @@ dependencies = [
"os_str_bytes",
]
[[package]]
name = "clap_lex"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8"
dependencies = [
"os_str_bytes",
]
[[package]]
name = "clipboard-win"
version = "4.4.2"
@ -354,7 +373,7 @@ dependencies = [
"atty",
"cast",
"ciborium",
"clap",
"clap 3.2.22",
"criterion-plot",
"itertools",
"lazy_static",

2
boa_cli/Cargo.toml

@ -16,7 +16,7 @@ boa_engine = { workspace = true, features = ["deser", "console"] }
boa_interner.workspace = true
rustyline = "10.0.0"
rustyline-derive = "0.7.0"
clap = { version = "3.2.22", features = ["derive"] }
clap = { version = "4.0.12", features = ["derive"] }
serde_json = "1.0.86"
colored = "2.0.0"
regex = "1.6.0"

20
boa_cli/src/main.rs

@ -60,7 +60,7 @@
)]
use boa_engine::{syntax::ast::node::StatementList, Context};
use clap::{ArgEnum, Parser};
use clap::{Parser, ValueEnum, ValueHint};
use colored::{Color, Colorize};
use rustyline::{config::Config, error::ReadlineError, EditMode, Editor};
use std::{fs::read, fs::OpenOptions, io, path::PathBuf};
@ -83,22 +83,28 @@ const READLINE_COLOR: Color = Color::Cyan;
// https://docs.rs/structopt/0.3.11/structopt/#type-magic
#[allow(clippy::option_option)]
#[derive(Debug, Parser)]
#[clap(author, version, about, name = "boa")]
#[command(author, version, about, name = "boa")]
struct Opt {
/// The JavaScript file(s) to be evaluated.
#[clap(name = "FILE", parse(from_os_str))]
#[arg(name = "FILE", value_hint = ValueHint::FilePath)]
files: Vec<PathBuf>,
/// Dump the AST to stdout with the given format.
#[clap(long, short = 'a', value_name = "FORMAT", ignore_case = true, arg_enum)]
#[arg(
long,
short = 'a',
value_name = "FORMAT",
ignore_case = true,
value_enum
)]
dump_ast: Option<Option<DumpFormat>>,
/// Dump the AST to stdout with the given format.
#[clap(long = "trace", short = 't')]
#[arg(long, short)]
trace: bool,
/// Use vi mode in the REPL
#[clap(long = "vi")]
#[arg(long = "vi")]
vi_mode: bool,
}
@ -109,7 +115,7 @@ impl Opt {
}
}
#[derive(Debug, Clone, ArgEnum)]
#[derive(Debug, Clone, ValueEnum)]
enum DumpFormat {
/// The different types of format available for dumping.
///

2
boa_tester/Cargo.toml

@ -15,7 +15,7 @@ rust-version.workspace = true
boa_engine = { workspace = true, features = ["intl"] }
boa_interner.workspace = true
boa_gc.workspace = true
clap = { version = "3.2.22", features = ["derive"] }
clap = { version = "4.0.12", features = ["derive"] }
serde = { version = "1.0.145", features = ["derive"] }
serde_yaml = "0.9.13"
serde_json = "1.0.86"

21
boa_tester/src/main.rs

@ -73,7 +73,7 @@ use self::{
};
use anyhow::{bail, Context};
use bitflags::bitflags;
use clap::Parser;
use clap::{ArgAction, Parser, ValueHint};
use colored::Colorize;
use fxhash::{FxHashMap, FxHashSet};
use once_cell::sync::Lazy;
@ -194,41 +194,42 @@ static IGNORED: Lazy<Ignored> = Lazy::new(|| {
/// Boa test262 tester
#[derive(Debug, Parser)]
#[clap(author, version, about, name = "Boa test262 tester")]
#[command(author, version, about, name = "Boa test262 tester")]
enum Cli {
/// Run the test suite.
Run {
/// Whether to show verbose output.
#[clap(short, long, parse(from_occurrences))]
#[arg(short, long, action = ArgAction::Count)]
verbose: u8,
/// Path to the Test262 suite.
#[clap(long, parse(from_os_str), default_value = "./test262")]
#[arg(long, default_value = "./test262", value_hint = ValueHint::DirPath)]
test262_path: PathBuf,
/// Which specific test or test suite to run. Should be a path relative to the Test262 directory: e.g. "test/language/types/number"
#[clap(short, long, parse(from_os_str), default_value = "test")]
#[arg(short, long, default_value = "test", value_hint = ValueHint::AnyPath)]
suite: PathBuf,
/// Optional output folder for the full results information.
#[clap(short, long, parse(from_os_str))]
#[arg(short, long, value_hint = ValueHint::DirPath)]
output: Option<PathBuf>,
/// Execute tests serially
#[clap(short, long)]
#[arg(short, long)]
disable_parallelism: bool,
},
/// Compare two test suite results.
Compare {
/// Base results of the suite.
#[clap(parse(from_os_str))]
#[arg(value_hint = ValueHint::FilePath)]
base: PathBuf,
/// New results to compare.
#[clap(parse(from_os_str))]
#[arg(value_hint = ValueHint::FilePath)]
new: PathBuf,
/// Whether to use markdown output
#[clap(short, long)]
#[arg(short, long)]
markdown: bool,
},
}

Loading…
Cancel
Save