mirror of
https://github.com/clap-rs/clap
synced 2025-01-18 23:53:54 +00:00
style: fix lints in yaml-related functions
This commit is contained in:
parent
215677bfa7
commit
102fb7d2ce
3 changed files with 15 additions and 20 deletions
|
@ -1422,16 +1422,14 @@ impl<'a> From<&'a Yaml> for App<'a, 'a> {
|
|||
a = a.setting(s.parse().expect("unknown AppSetting found in YAML file"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if let Some(v) = yaml["settings"].as_str() {
|
||||
a = a.setting(v.parse().expect("unknown AppSetting found in YAML file"));
|
||||
} else if yaml["settings"] != Yaml::BadValue {
|
||||
panic!("Failed to convert YAML value {:?} to a string",
|
||||
yaml["settings"]);
|
||||
}
|
||||
} else if let Some(v) = yaml["settings"].as_str() {
|
||||
a = a.setting(v.parse().expect("unknown AppSetting found in YAML file"));
|
||||
} else if yaml["settings"] != Yaml::BadValue {
|
||||
panic!("Failed to convert YAML value {:?} to a string",
|
||||
yaml["settings"]);
|
||||
}
|
||||
if let Some(v) = yaml["global_setting"].as_str() {
|
||||
a = a.setting(v.parse().ok().expect("unknown AppSetting found in YAML file"));
|
||||
a = a.setting(v.parse().expect("unknown AppSetting found in YAML file"));
|
||||
} else if yaml["global_setting"] != Yaml::BadValue {
|
||||
panic!("Failed to convert YAML value {:?} to an AppSetting",
|
||||
yaml["setting"]);
|
||||
|
@ -1440,17 +1438,14 @@ impl<'a> From<&'a Yaml> for App<'a, 'a> {
|
|||
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"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if let Some(v) = yaml["global_settings"].as_str() {
|
||||
a = a.global_setting(v.parse().expect("unknown AppSetting found in YAML file"));
|
||||
} else if yaml["global_settings"] != Yaml::BadValue {
|
||||
panic!("Failed to convert YAML value {:?} to a string",
|
||||
yaml["global_settings"]);
|
||||
}
|
||||
} else if let Some(v) = yaml["global_settings"].as_str() {
|
||||
a = a.global_setting(v.parse().expect("unknown AppSetting found in YAML file"));
|
||||
} else if yaml["global_settings"] != Yaml::BadValue {
|
||||
panic!("Failed to convert YAML value {:?} to a string",
|
||||
yaml["global_settings"]);
|
||||
}
|
||||
|
||||
macro_rules! vec_or_str {
|
||||
|
@ -1481,12 +1476,12 @@ impl<'a> From<&'a Yaml> for App<'a, 'a> {
|
|||
|
||||
if let Some(v) = yaml["args"].as_vec() {
|
||||
for arg_yaml in v {
|
||||
a = a.arg(Arg::from_yaml(&arg_yaml.as_hash().unwrap()));
|
||||
a = a.arg(Arg::from_yaml(arg_yaml.as_hash().unwrap()));
|
||||
}
|
||||
}
|
||||
if let Some(v) = yaml["subcommands"].as_vec() {
|
||||
for sc_yaml in v {
|
||||
a = a.subcommand(SubCommand::from_yaml(&sc_yaml));
|
||||
a = a.subcommand(SubCommand::from_yaml(sc_yaml));
|
||||
}
|
||||
}
|
||||
if let Some(v) = yaml["groups"].as_vec() {
|
||||
|
|
|
@ -141,7 +141,7 @@ impl<'a, 'b> Arg<'a, 'b> {
|
|||
/// ```
|
||||
/// [`Arg`]: ./struct.Arg.html
|
||||
#[cfg(feature = "yaml")]
|
||||
pub fn from_yaml<'y>(y: &'y BTreeMap<Yaml, Yaml>) -> Arg<'y, 'y> {
|
||||
pub fn from_yaml(y: &BTreeMap<Yaml, Yaml>) -> Arg {
|
||||
// We WANT this to panic on error...so expect() is good.
|
||||
let name_yml = y.keys().nth(0).unwrap();
|
||||
let name_str = name_yml.as_str().unwrap();
|
||||
|
|
|
@ -62,7 +62,7 @@ impl<'a> SubCommand<'a> {
|
|||
/// let sc = SubCommand::from_yaml(sc_yaml);
|
||||
/// ```
|
||||
#[cfg(feature = "yaml")]
|
||||
pub fn from_yaml<'y>(yaml: &'y Yaml) -> App<'y, 'y> {
|
||||
pub fn from_yaml(yaml: &Yaml) -> App {
|
||||
App::from_yaml(yaml)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue