use rslint_cli::ExplanationRunner;
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
#[structopt(
name = "rslint",
about = "An extremely fast and configurable JavaScript linter"
)]
pub(crate) struct Options {
#[structopt(short, long)]
verbose: bool,
#[structopt(default_value = "./")]
files: String,
#[structopt(subcommand)]
cmd: Option<SubCommand>,
#[structopt(short, long)]
fix: bool,
#[structopt(short = "D", long)]
dirty: bool,
}
#[derive(Debug, StructOpt)]
pub(crate) enum SubCommand {
Explain { rules: Vec<String> },
}
fn main() {
#[cfg(not(debug_assertions))]
std::panic::set_hook(Box::new(rslint_cli::panic_hook));
let opt = Options::from_args();
if let Some(SubCommand::Explain { rules }) = opt.cmd {
ExplanationRunner::new(rules).print();
} else {
rslint_cli::run(opt.files, opt.verbose, opt.fix, opt.dirty);
}
}