Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Upgrade clap to 4.0, add value hints for zsh and fish #2336

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion boa_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.11", features = ["derive"] }
serde_json = "1.0.85"
colored = "2.0.0"
regex = "1.6.0"
Expand Down
20 changes: 13 additions & 7 deletions boa_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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,
}

Expand All @@ -109,7 +115,7 @@ impl Opt {
}
}

#[derive(Debug, Clone, ArgEnum)]
#[derive(Debug, Clone, ValueEnum)]
enum DumpFormat {
/// The different types of format available for dumping.
///
Expand Down
2 changes: 1 addition & 1 deletion boa_tester/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.11", features = ["derive"] }
serde = { version = "1.0.145", features = ["derive"] }
serde_yaml = "0.9.13"
serde_json = "1.0.85"
Expand Down
21 changes: 11 additions & 10 deletions boa_tester/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ use self::{
};
use anyhow::{bail, Context};
use bitflags::bitflags;
use clap::Parser;
use clap::{Parser, ValueHint};
use colored::Colorize;
use fxhash::{FxHashMap, FxHashSet};
use once_cell::sync::Lazy;
Expand Down Expand Up @@ -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 = clap::ArgAction::Count)]
Razican marked this conversation as resolved.
Show resolved Hide resolved
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(short, long, value_hint = ValueHint::DirPath)]
base: PathBuf,

/// New results to compare.
#[clap(parse(from_os_str))]
#[arg(short, long, value_hint = ValueHint::DirPath)]
new: PathBuf,

/// Whether to use markdown output
#[clap(short, long)]
#[arg(short, long)]
markdown: bool,
},
}
Expand Down