Skip to content

Commit

Permalink
Fixes for Clap.
Browse files Browse the repository at this point in the history
  • Loading branch information
elliottslaughter committed Feb 12, 2023
1 parent ddfbf25 commit 4864fd1
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,14 @@ fn parse_args() -> Action {
.about("Creates an integrity database from a directory")
.arg(
clap::Arg::with_name("database")
.value_parser(value_parser!(OsString))
.help("Path of integrity database to create")
.required(true)
.index(1),
)
.arg(
clap::Arg::with_name("path")
.value_parser(value_parser!(OsString))
.help("Path of file or directory to scan")
.required(true)
.index(2),
Expand All @@ -142,12 +144,14 @@ fn parse_args() -> Action {
.about("Check an integrity database against a directory")
.arg(
clap::Arg::with_name("database")
.value_parser(value_parser!(OsString))
.help("Path of integrity database to read")
.required(true)
.index(1),
)
.arg(
clap::Arg::with_name("path")
.value_parser(value_parser!(OsString))
.help("Path of file or directory to scan")
.required(true)
.index(2),
Expand All @@ -159,12 +163,14 @@ fn parse_args() -> Action {
.about("Compare two integrity databases")
.arg(
clap::Arg::with_name("old")
.value_parser(value_parser!(OsString))
.help("Path of old integrity database")
.required(true)
.index(1),
)
.arg(
clap::Arg::with_name("new")
.value_parser(value_parser!(OsString))
.help("Path of new integrity database")
.required(true)
.index(2),
Expand All @@ -175,6 +181,7 @@ fn parse_args() -> Action {
.about("Check the internal consistency of an integrity database")
.arg(
clap::Arg::with_name("database")
.value_parser(value_parser!(OsString))
.help("Path of integrity database to read")
.required(true)
.index(1),
Expand All @@ -190,24 +197,33 @@ fn parse_args() -> Action {
.get_matches();
match matches.subcommand() {
Some(("build", submatches)) => Action::Build {
db_path: submatches.value_of_os("database").unwrap().to_owned(),
dir_path: submatches.value_of_os("path").unwrap().to_owned(),
db_path: submatches
.get_one::<OsString>("database")
.unwrap()
.to_owned(),
dir_path: submatches.get_one::<OsString>("path").unwrap().to_owned(),
features: parse_features(submatches),
threads: parse_threads(submatches),
force: submatches.is_present("force"),
},
Some(("check", submatches)) => Action::Check {
db_path: submatches.value_of_os("database").unwrap().to_owned(),
dir_path: submatches.value_of_os("path").unwrap().to_owned(),
db_path: submatches
.get_one::<OsString>("database")
.unwrap()
.to_owned(),
dir_path: submatches.get_one::<OsString>("path").unwrap().to_owned(),
features: parse_features(submatches),
threads: parse_threads(submatches),
},
Some(("diff", submatches)) => Action::Diff {
old_path: submatches.value_of_os("old").unwrap().to_owned(),
new_path: submatches.value_of_os("new").unwrap().to_owned(),
old_path: submatches.get_one::<OsString>("old").unwrap().to_owned(),
new_path: submatches.get_one::<OsString>("new").unwrap().to_owned(),
},
Some(("selfcheck", submatches)) => Action::SelfCheck {
db_path: submatches.value_of_os("database").unwrap().to_owned(),
db_path: submatches
.get_one::<OsString>("database")
.unwrap()
.to_owned(),
},
_ => unreachable!(),
}
Expand Down

0 comments on commit 4864fd1

Please sign in to comment.