Skip to content

Commit

Permalink
fix(YAML): adds missing YAML methods for App and Arg
Browse files Browse the repository at this point in the history
Closes #528
  • Loading branch information
kbknapp committed Jun 13, 2016
1 parent eb7521a commit e468faf
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,12 @@ impl<'a> From<&'a Yaml> for App<'a, 'a> {
if let Some(v) = yaml["about"].as_str() {
a = a.about(v);
}
if let Some(v) = yaml["before_help"].as_str() {
a = a.before_help(v);
}
if let Some(v) = yaml["template"].as_str() {
a = a.template(v);
}
if let Some(v) = yaml["after_help"].as_str() {
a = a.after_help(v);
}
Expand All @@ -1157,20 +1163,46 @@ impl<'a> From<&'a Yaml> for App<'a, 'a> {
if let Some(v) = yaml["version_short"].as_str() {
a = a.version_short(v);
}
if let Some(v) = yaml["setting"].as_str() {
a = a.setting(v.parse().ok().expect("unknown AppSetting found in YAML file"));
}
if let Some(v) = yaml["settings"].as_vec() {
for ys in v {
if let Some(s) = ys.as_str() {
a = a.setting(s.parse().ok().expect("unknown AppSetting found in YAML file"));
}
}
}
if let Some(v) = yaml["global_setting"].as_str() {
a = a.setting(v.parse().ok().expect("unknown AppSetting found in YAML file"));
}
if let Some(v) = yaml["global_settings"].as_vec() {
for ys in v {
if let Some(s) = ys.as_str() {
a = a.global_setting(s.parse().ok().expect("unknown AppSetting found in YAML file"));
}
}
}
if let Some(v) = yaml["alias"].as_str() {
a = a.alias(v);
}
if let Some(v) = yaml["aliases"].as_vec() {
for ys in v {
if let Some(s) = ys.as_str() {
a = a.alias(s);
}
}
}
if let Some(v) = yaml["visible_alias"].as_str() {
a = a.visible_alias(v);
}
if let Some(v) = yaml["visible_aliases"].as_vec() {
for ys in v {
if let Some(s) = ys.as_str() {
a = a.visible_alias(s);
}
}
}
if let Some(v) = yaml["args"].as_vec() {
for arg_yaml in v {
a = a.arg(Arg::from_yaml(&arg_yaml.as_hash().unwrap()));
Expand Down
3 changes: 3 additions & 0 deletions src/args/arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ impl<'a, 'b> Arg<'a, 'b> {
"index" => a.index(v.as_i64().unwrap() as u64),
"global" => a.global(v.as_bool().unwrap()),
"multiple" => a.multiple(v.as_bool().unwrap()),
"hidden" => a.hidden(v.as_bool().unwrap()),
"next_line_help" => a.next_line_help(v.as_bool().unwrap()),
"empty_values" => a.empty_values(v.as_bool().unwrap()),
"group" => a.group(v.as_str().unwrap()),
"number_of_values" => a.number_of_values(v.as_i64().unwrap() as u64),
Expand All @@ -165,6 +167,7 @@ impl<'a, 'b> Arg<'a, 'b> {
"value_delimiter" => a.value_delimiter(v.as_str().unwrap()),
"required_unless" => a.required_unless(v.as_str().unwrap()),
"display_order" => a.display_order(v.as_i64().unwrap() as usize),
"default_value" => a.default_value(v.as_str().unwrap()),
"value_names" => {
for ys in v.as_vec().unwrap() {
if let Some(s) = ys.as_str() {
Expand Down

0 comments on commit e468faf

Please sign in to comment.