mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 06:42:33 +00:00
Consistent From<Yaml> for ArgGroup
This commit is contained in:
parent
ddaa371d0c
commit
aab2e41f8a
3 changed files with 14 additions and 19 deletions
|
@ -2190,7 +2190,7 @@ impl<'a> From<&'a Yaml> for App<'a> {
|
|||
}
|
||||
if let Some(v) = yaml["groups"].as_vec() {
|
||||
for ag_yaml in v {
|
||||
a = a.group(ArgGroup::from(ag_yaml.as_hash().unwrap()));
|
||||
a = a.group(ArgGroup::from(ag_yaml));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -414,22 +414,6 @@ impl<'a> Debug for ArgGroup<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "yaml")]
|
||||
impl<'a> From<&'a Yaml> for ArgGroup<'a> {
|
||||
/// Creates a new instance of `ArgGroup` from a .yml (YAML) file.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```ignore
|
||||
/// # use clap::{ArgGroup, load_yaml};
|
||||
/// let yml = load_yaml!("group.yml");
|
||||
/// let ag = ArgGroup::from(yml);
|
||||
/// ```
|
||||
fn from(y: &'a Yaml) -> Self {
|
||||
ArgGroup::from(y.as_hash().unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'z> From<&'z ArgGroup<'a>> for ArgGroup<'a> {
|
||||
fn from(g: &'z ArgGroup<'a>) -> Self {
|
||||
ArgGroup {
|
||||
|
@ -445,8 +429,18 @@ impl<'a, 'z> From<&'z ArgGroup<'a>> for ArgGroup<'a> {
|
|||
}
|
||||
|
||||
#[cfg(feature = "yaml")]
|
||||
impl<'a> From<&'a yaml_rust::yaml::Hash> for ArgGroup<'a> {
|
||||
fn from(b: &'a yaml_rust::yaml::Hash) -> Self {
|
||||
impl<'a> From<&'a Yaml> for ArgGroup<'a> {
|
||||
/// Creates a new instance of `ArgGroup` from a .yml (YAML) file.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```ignore
|
||||
/// # use clap::{ArgGroup, load_yaml};
|
||||
/// let yml = load_yaml!("group.yml");
|
||||
/// let ag = ArgGroup::from(yml);
|
||||
/// ```
|
||||
fn from(y: &'a Yaml) -> Self {
|
||||
let b = y.as_hash().expect("ArgGroup::from::<Yaml> expects a table");
|
||||
// We WANT this to panic on error...so expect() is good.
|
||||
let mut a = ArgGroup::default();
|
||||
let group_settings = if b.len() == 1 {
|
||||
|
|
|
@ -29,6 +29,7 @@ pub use crate::{
|
|||
};
|
||||
|
||||
#[cfg(feature = "yaml")]
|
||||
#[cfg_attr(feature = "yaml", doc(hidden))]
|
||||
pub use yaml_rust::YamlLoader;
|
||||
|
||||
#[cfg(feature = "derive")]
|
||||
|
|
Loading…
Reference in a new issue