Skip to content

Commit 129cc6b

Browse files
committed
refactor(fluent-cli): Overhaul CLI using current version of Clap
1 parent c748e5e commit 129cc6b

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

fluent-cli/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ for Fluent Localization System.
66
"""
77
version = "0.0.1"
88
edition.workspace = true
9-
rust-version.workspace = true
9+
rust-version = "1.74.0"
1010
homepage.workspace = true
1111
repository.workspace = true
1212
license.workspace = true
@@ -29,4 +29,4 @@ fluent-syntax.workspace = true
2929
serde = { workspace = true, features = ["derive"]}
3030
serde_json.workspace = true
3131
annotate-snippets = { version = "0.6", features = ["color"] }
32-
clap = "2.33"
32+
clap = "4.5"

fluent-cli/src/main.rs

+16-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
1-
use clap::App;
1+
use clap::{Arg, ArgAction, Command};
22

33
use fluent_cli::parse_file;
44

55
fn main() {
6-
let matches = App::new("Fluent Parser")
6+
let matches = Command::new("Fluent Parser")
77
.version("0.0.1")
88
.about("Parses FTL file into an AST")
9-
.args_from_usage(
10-
"-s, --silent 'Disables error reporting'
11-
<FILE> 'FTL file to parse'",
9+
.arg(
10+
Arg::new("silent")
11+
.short('s')
12+
.long("silent")
13+
.action(ArgAction::SetTrue)
14+
.help("Disables error reporting")
15+
)
16+
.arg(
17+
Arg::new("FILE")
18+
.required(true)
19+
.help("FTL file to parse")
1220
)
1321
.get_matches();
1422

15-
let input = matches.value_of("FILE").unwrap();
16-
parse_file(input, matches.is_present("silent"));
23+
let input: &String = matches.get_one("FILE").unwrap();
24+
let silent: bool = *matches.get_one("silent").unwrap();
25+
parse_file(input, silent);
1726
}

0 commit comments

Comments
 (0)