From 04badf8a8ed0f20239a9bc9f7c6b932167b005e9 Mon Sep 17 00:00:00 2001 From: Andrew Hlynskyi Date: Wed, 23 Jun 2021 10:56:23 +0300 Subject: [PATCH 1/5] feat(cli): Enable clap colored help --- cli/src/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/cli/src/main.rs b/cli/src/main.rs index 53598bc6..718dcd02 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -40,6 +40,7 @@ fn run() -> Result<()> { .setting(AppSettings::SubcommandRequiredElseHelp) .author("Max Brunsfeld ") .about("Generates and tests parsers") + .global_setting(AppSettings::ColoredHelp) .subcommand(SubCommand::with_name("init-config").about("Generate a default config file")) .subcommand( SubCommand::with_name("generate") From 80ee33b073f79d1c3cbf2afe9cef097469b79233 Mon Sep 17 00:00:00 2001 From: Andrew Hlynskyi Date: Wed, 23 Jun 2021 10:57:26 +0300 Subject: [PATCH 2/5] feat(cli): Add short aliases for frequent subcommands --- cli/src/main.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cli/src/main.rs b/cli/src/main.rs index 718dcd02..c0615d9a 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -44,6 +44,8 @@ fn run() -> Result<()> { .subcommand(SubCommand::with_name("init-config").about("Generate a default config file")) .subcommand( SubCommand::with_name("generate") + .alias("gen") + .alias("g") .about("Generate a parser") .arg(Arg::with_name("grammar-path").index(1)) .arg(Arg::with_name("log").long("log")) @@ -59,6 +61,7 @@ fn run() -> Result<()> { ) .subcommand( SubCommand::with_name("parse") + .alias("p") .about("Parse files") .arg(Arg::with_name("paths-file").long("paths").takes_value(true)) .arg( @@ -86,6 +89,7 @@ fn run() -> Result<()> { ) .subcommand( SubCommand::with_name("query") + .alias("q") .about("Search files using a syntax tree query") .arg(Arg::with_name("query-path").index(1).required(true)) .arg(Arg::with_name("paths-file").long("paths").takes_value(true)) @@ -120,6 +124,7 @@ fn run() -> Result<()> { ) .subcommand( SubCommand::with_name("test") + .alias("t") .about("Run a parser's tests") .arg( Arg::with_name("filter") @@ -154,6 +159,7 @@ fn run() -> Result<()> { ) .subcommand( SubCommand::with_name("build-wasm") + .alias("bw") .about("Compile a parser to WASM") .arg( Arg::with_name("docker") From 1220ec3852d17b203bb91b14481f6a66304d5316 Mon Sep 17 00:00:00 2001 From: Andrew Hlynskyi Date: Wed, 23 Jun 2021 10:58:01 +0300 Subject: [PATCH 3/5] feat(cli): Rename web-ui -> playground with fallback alias --- cli/src/main.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cli/src/main.rs b/cli/src/main.rs index c0615d9a..6334d916 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -169,8 +169,11 @@ fn run() -> Result<()> { .arg(Arg::with_name("path").index(1).multiple(true)), ) .subcommand( - SubCommand::with_name("web-ui") - .about("Test a parser interactively in the browser") + SubCommand::with_name("playground") + .alias("play") + .alias("pg") + .alias("web-ui") + .about("Start local playground for a parser in the browser") .arg( Arg::with_name("quiet") .long("quiet") @@ -437,7 +440,7 @@ fn run() -> Result<()> { wasm::compile_language_to_wasm(&grammar_path, matches.is_present("docker"))?; } - ("web-ui", Some(matches)) => { + ("playground", Some(matches)) => { let open_in_browser = !matches.is_present("quiet"); web_ui::serve(¤t_dir, open_in_browser); } From 650ee948004c2a448dfcf19d4241be6f643498ba Mon Sep 17 00:00:00 2001 From: Andrew Hlynskyi Date: Wed, 23 Jun 2021 11:16:41 +0300 Subject: [PATCH 4/5] fix(cli): disable help subcommand, -h, --help are enough --- cli/src/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/cli/src/main.rs b/cli/src/main.rs index 6334d916..af25c2fd 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -41,6 +41,7 @@ fn run() -> Result<()> { .author("Max Brunsfeld ") .about("Generates and tests parsers") .global_setting(AppSettings::ColoredHelp) + .global_setting(AppSettings::DisableHelpSubcommand) .subcommand(SubCommand::with_name("init-config").about("Generate a default config file")) .subcommand( SubCommand::with_name("generate") From bd0e60240eccf91b4573e1a268d8d12a98741e67 Mon Sep 17 00:00:00 2001 From: Andrew Hlynskyi Date: Thu, 24 Jun 2021 12:03:59 +0300 Subject: [PATCH 5/5] fix(cli): Change -h -> -H for the highlight subcommand to don't clash with the help flag --- cli/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/src/main.rs b/cli/src/main.rs index af25c2fd..983fd1e4 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -154,7 +154,7 @@ fn run() -> Result<()> { .required(false), ) .arg(Arg::with_name("scope").long("scope").takes_value(true)) - .arg(Arg::with_name("html").long("html").short("h")) + .arg(Arg::with_name("html").long("html").short("H")) .arg(Arg::with_name("time").long("time").short("t")) .arg(Arg::with_name("quiet").long("quiet").short("q")), )