Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
- Remove `num_args` call that wasn't supposed to be there
- Factor out shared value parser with non-trivial init
  • Loading branch information
dlsmith committed May 15, 2023
1 parent 0bfc21c commit 855785f
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions crates/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ pub fn build_app() -> Command {
.allow_hyphen_values(true)
.last(true);

let build_target_values_parser =
PossibleValuesParser::new(Target::iter().map(Into::<&'static str>::into));
let app = Command::new("roc")
.version(concatcp!(VERSION, "\n"))
.about("Run the given .roc file, if there are no compilation errors.\nYou can use one of the SUBCOMMANDS below to do something else!")
Expand All @@ -162,12 +164,7 @@ pub fn build_app() -> Command {
.long(FLAG_TARGET)
.help("Choose a different target")
.default_value(Into::<&'static str>::into(Target::default()))
.value_parser(
PossibleValuesParser::new(
Target::iter().map(|target| {
Into::<&'static str>::into(target)
})
))
.value_parser(build_target_values_parser.clone())
.required(false),
)
.arg(
Expand Down Expand Up @@ -283,7 +280,6 @@ pub fn build_app() -> Command {
.about("Generate documentation for a Roc package")
.arg(Arg::new(ROC_FILE)
.help("The package's main .roc file")
.num_args(0..0)
.value_parser(value_parser!(PathBuf))
.required(false)
.default_value(DEFAULT_ROC_FILENAME),
Expand Down Expand Up @@ -325,12 +321,7 @@ pub fn build_app() -> Command {
.long(FLAG_TARGET)
.help("Choose a different target")
.default_value(Into::<&'static str>::into(Target::default()))
.value_parser(
PossibleValuesParser::new(
Target::iter().map(|target| {
Into::<&'static str>::into(target)
})
))
.value_parser(build_target_values_parser)
.required(false),
)
)
Expand Down

0 comments on commit 855785f

Please sign in to comment.