aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nitrocli/src/arg_util.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/nitrocli/src/arg_util.rs b/nitrocli/src/arg_util.rs
index 3e4ba85..5980f48 100644
--- a/nitrocli/src/arg_util.rs
+++ b/nitrocli/src/arg_util.rs
@@ -107,14 +107,23 @@ macro_rules! enum_int {
}
impl ::std::str::FromStr for $name {
- type Err = ();
+ type Err = ::std::string::String;
fn from_str(s: &str) -> ::std::result::Result<Self, Self::Err> {
match s {
$(
$str => Ok($name::$var),
)*
- _ => Err(()),
+ _ => Err(
+ format!(
+ "expected one of {}",
+ $name::all_variants()
+ .iter()
+ .map(::std::convert::AsRef::as_ref)
+ .collect::<::std::vec::Vec<_>>()
+ .join(", "),
+ )
+ )
}
}
}