Skip to content

Commit

Permalink
refactor(fluent-cli): Overhaul CLI using current version of Clap
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed May 27, 2024
1 parent c748e5e commit 11dd0e8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions fluent-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
19 changes: 12 additions & 7 deletions fluent-cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -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'
<FILE> '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);
}

0 comments on commit 11dd0e8

Please sign in to comment.