extern crate clap as _clap;
extern crate failure;
extern crate serde as _serde;
extern crate structopt as _structopt;
#[allow(unused_imports)]
#[macro_use]
extern crate structopt_yaml_derive;
#[doc(hidden)]
pub use structopt_yaml_derive::*;
use std::ffi::OsString;
pub mod clap {
pub use _clap::*;
}
pub mod serde {
pub use _serde::*;
}
pub mod structopt {
pub use _structopt::*;
}
pub trait StructOptYaml {
fn merge<'a>(from_yaml: Self, from_args: Self, args: &_clap::ArgMatches) -> Self
where
Self: Sized,
Self: _structopt::StructOpt,
Self: _serde::de::Deserialize<'a>;
fn from_clap_with_yaml(yaml_str: &str, args: &_clap::ArgMatches) -> Result<Self, failure::Error>
where
Self: Sized,
Self: _structopt::StructOpt,
Self: _serde::de::DeserializeOwned,
{
let from_args: Self = _structopt::StructOpt::from_clap(&args);
let from_yaml: Self = serde_yaml::from_str(&yaml_str)?;
Ok(Self::merge(from_yaml, from_args, &args))
}
fn from_args_with_yaml<'a>(yaml_str: &'a str) -> Result<Self, failure::Error>
where
Self: Sized,
Self: _structopt::StructOpt,
Self: _serde::de::DeserializeOwned,
{
let clap = Self::clap();
let args = clap.get_matches();
Self::from_clap_with_yaml(yaml_str, &args)
}
fn from_iter_with_yaml<'a, I>(yaml_str: &'a str, iter: I) -> Result<Self, failure::Error>
where
Self: Sized,
Self: _structopt::StructOpt,
Self: _serde::de::DeserializeOwned,
I: IntoIterator,
I::Item: Into<OsString> + Clone,
{
let clap = Self::clap();
let args = clap.get_matches_from(iter);
Self::from_clap_with_yaml(yaml_str, &args)
}
}