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] - migrated to clap 3 #1957

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
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
78 changes: 72 additions & 6 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 = { path = "../boa_engine", features = ["deser", "console"], version
boa_interner = { path = "../boa_interner", version = "0.14.0" }
rustyline = "9.1.2"
rustyline-derive = "0.6.0"
structopt = "0.3.26"
clap = { version = "3.1.6", features = ["derive"] }
serde_json = "1.0.79"
colored = "2.0.0"
regex = "1.5.5"
Expand Down
31 changes: 20 additions & 11 deletions boa_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ use boa_interner::Interner;
use colored::{Color, Colorize};
use rustyline::{config::Config, error::ReadlineError, EditMode, Editor};
use std::{fs::read, io, path::PathBuf};
use structopt::{clap::arg_enum, StructOpt};

//use structopt::{clap::arg_enum, StructOpt};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is no longer needed, right?

use clap::{ArgEnum, Parser};
mod helper;

#[cfg(all(target_arch = "x86_64", target_os = "linux", target_env = "gnu"))]
Expand All @@ -84,29 +84,29 @@ const READLINE_COLOR: Color = Color::Cyan;
// is an optional argument that optionally takes a value ([--opt=[val]]).
// https://docs.rs/structopt/0.3.11/structopt/#type-magic
#[allow(clippy::option_option)]
#[derive(Debug, StructOpt)]
#[structopt(author, about, name = "boa")]
#[derive(Debug, Parser)]
#[clap(author, about, name = "boa")]
struct Opt {
/// The JavaScript file(s) to be evaluated.
#[structopt(name = "FILE", parse(from_os_str))]
#[clap(name = "FILE", parse(from_os_str))]
files: Vec<PathBuf>,

/// Dump the AST to stdout with the given format.
#[structopt(
#[clap(
long,
short = "a",
short = 'a',
value_name = "FORMAT",
possible_values = &DumpFormat::variants(),
case_insensitive = true
case_insensitive = true,
arg_enum
)]
dump_ast: Option<Option<DumpFormat>>,

/// Dump the AST to stdout with the given format.
#[structopt(long = "trace", short = "t")]
#[clap(long = "trace", short = 't')]
trace: bool,

/// Use vi mode in the REPL
#[structopt(long = "vi")]
#[clap(long = "vi")]
vi_mode: bool,
}

Expand All @@ -117,6 +117,7 @@ impl Opt {
}
}

/*
arg_enum! {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is no longer needed, can it be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah i think it should be removed.

/// The different types of format available for dumping.
///
Expand All @@ -137,6 +138,14 @@ arg_enum! {
// This is a pretty printed json format.
JsonPretty,
}
} **/

#[derive(Debug, Clone, ArgEnum)]
#[clap(name = 'a')]
enum DumpFormat {
Debug,
Json,
JsonPretty,
}

/// Parses the the token stream into an AST and returns it.
Expand Down