mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 07:41:12 +00:00
Use matches.value_of_t
This commit is contained in:
parent
da3490be8b
commit
d337a80ff5
2 changed files with 11 additions and 13 deletions
|
@ -669,15 +669,15 @@ impl std::fmt::Display for Target {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::str::FromStr for Target {
|
impl std::str::FromStr for Target {
|
||||||
type Err = ();
|
type Err = String;
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(string: &str) -> Result<Self, Self::Err> {
|
||||||
match s {
|
match string {
|
||||||
"system" => Ok(Target::System),
|
"system" => Ok(Target::System),
|
||||||
"linux32" => Ok(Target::Linux32),
|
"linux32" => Ok(Target::Linux32),
|
||||||
"linux64" => Ok(Target::Linux64),
|
"linux64" => Ok(Target::Linux64),
|
||||||
"wasm32" => Ok(Target::Wasm32),
|
"wasm32" => Ok(Target::Wasm32),
|
||||||
_ => Err(()),
|
_ => Err(format!("Roc does not know how to compile to {}", string)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,14 +67,7 @@ fn main() -> io::Result<()> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some((CMD_BUILD, matches)) => {
|
Some((CMD_BUILD, matches)) => {
|
||||||
use std::str::FromStr;
|
let target: Target = matches.value_of_t(FLAG_TARGET).unwrap_or_default();
|
||||||
|
|
||||||
let target = match matches.value_of(FLAG_TARGET) {
|
|
||||||
Some(name) => Target::from_str(name).unwrap(),
|
|
||||||
None => Target::default(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let triple = target.to_triple();
|
|
||||||
|
|
||||||
let link_type = match (
|
let link_type = match (
|
||||||
matches.is_present(FLAG_LIB),
|
matches.is_present(FLAG_LIB),
|
||||||
|
@ -86,7 +79,12 @@ fn main() -> io::Result<()> {
|
||||||
(false, false) => LinkType::Executable,
|
(false, false) => LinkType::Executable,
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(build(matches, BuildConfig::BuildOnly, triple, link_type)?)
|
Ok(build(
|
||||||
|
matches,
|
||||||
|
BuildConfig::BuildOnly,
|
||||||
|
target.to_triple(),
|
||||||
|
link_type,
|
||||||
|
)?)
|
||||||
}
|
}
|
||||||
Some((CMD_CHECK, matches)) => {
|
Some((CMD_CHECK, matches)) => {
|
||||||
let arena = bumpalo::Bump::new();
|
let arena = bumpalo::Bump::new();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue