From c748e5ed138d2a4c8142b769222607f7bc6f6fc0 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 9 May 2024 11:56:48 +0300 Subject: [PATCH 1/2] chore(fluent-cli): Unblock building of CLI tooling in workspace --- Cargo.toml | 3 --- fluent-cli/src/main.rs | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 89a3dbea..6e1d838f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,9 +9,6 @@ members = [ "fluent-testing", "fluent", "intl-memoizer", -] - -exclude = [ "fluent-cli", ] diff --git a/fluent-cli/src/main.rs b/fluent-cli/src/main.rs index d0ef62ef..2b121a01 100644 --- a/fluent-cli/src/main.rs +++ b/fluent-cli/src/main.rs @@ -4,7 +4,7 @@ use fluent_cli::parse_file; fn main() { let matches = App::new("Fluent Parser") - .version("1.0") + .version("0.0.1") .about("Parses FTL file into an AST") .args_from_usage( "-s, --silent 'Disables error reporting' From 11dd0e896ce1d7eead80eaf561029578e64ef874 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 9 May 2024 13:00:53 +0300 Subject: [PATCH 2/2] refactor(fluent-cli): Overhaul CLI using current version of Clap --- fluent-cli/Cargo.toml | 4 ++-- fluent-cli/src/main.rs | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/fluent-cli/Cargo.toml b/fluent-cli/Cargo.toml index 123d3198..9062e37a 100644 --- a/fluent-cli/Cargo.toml +++ b/fluent-cli/Cargo.toml @@ -6,7 +6,7 @@ for Fluent Localization System. """ version = "0.0.1" edition.workspace = true -rust-version.workspace = true +rust-version = "1.74.0" homepage.workspace = true repository.workspace = true license.workspace = true @@ -29,4 +29,4 @@ fluent-syntax.workspace = true serde = { workspace = true, features = ["derive"]} serde_json.workspace = true annotate-snippets = { version = "0.6", features = ["color"] } -clap = "2.33" +clap = "4.5" diff --git a/fluent-cli/src/main.rs b/fluent-cli/src/main.rs index 2b121a01..bbe4bed1 100644 --- a/fluent-cli/src/main.rs +++ b/fluent-cli/src/main.rs @@ -1,17 +1,22 @@ -use clap::App; +use clap::{Arg, ArgAction, Command}; use fluent_cli::parse_file; fn main() { - let matches = App::new("Fluent Parser") + let matches = Command::new("Fluent Parser") .version("0.0.1") .about("Parses FTL file into an AST") - .args_from_usage( - "-s, --silent 'Disables error reporting' - 'FTL file to parse'", + .arg( + Arg::new("silent") + .short('s') + .long("silent") + .action(ArgAction::SetTrue) + .help("Disables error reporting"), ) + .arg(Arg::new("FILE").required(true).help("FTL file to parse")) .get_matches(); - let input = matches.value_of("FILE").unwrap(); - parse_file(input, matches.is_present("silent")); + let input: &String = matches.get_one("FILE").unwrap(); + let silent: bool = *matches.get_one("silent").unwrap(); + parse_file(input, silent); }