Skip to content

Commit

Permalink
imp(yaml): Updated yaml-rust to 0.4
Browse files Browse the repository at this point in the history
Closes #747, #1110
  • Loading branch information
savish committed Jun 22, 2018
1 parent 05c8ab8 commit 8a7ac8f
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ unicode-width = "0.1.4"
textwrap = "0.10.0"
indexmap = "1.0.1"
strsim = { version = "0.7.0", optional = true }
yaml-rust = { version = "0.3.5", optional = true }
yaml-rust = { version = "0.4", optional = true }
clippy = { version = "~0.0.166", optional = true }
atty = { version = "0.2.2", optional = true }
vec_map = { version = "0.8", optional = true }
Expand Down
4 changes: 2 additions & 2 deletions src/build/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1792,7 +1792,7 @@ impl<'a, 'b> App<'a, 'b> {
}

/// **Deprecated:** Use
#[deprecated(since="2.30.0", note="Use serde instead. Will be removed in v3.0-beta")]
#[deprecated(since="2.30.0", note="Use App::from instead. Will be removed in v3.0-beta")]
#[cfg(feature = "yaml")]
pub fn from_yaml(yaml: &'a Yaml) -> App<'a, 'a> { App::from(yaml) }

Expand Down Expand Up @@ -1951,7 +1951,7 @@ impl<'a, 'b> App<'a, 'b> {
#[cfg(feature = "yaml")]
impl<'a> From<&'a Yaml> for App<'a, 'a> {
fn from(mut yaml: &'a Yaml) -> Self {
use args::SubCommand;
use parse::SubCommand;
// We WANT this to panic on error...so expect() is good.
let mut is_sc = None;
let mut a = if let Some(name) = yaml["name"].as_str() {
Expand Down
8 changes: 2 additions & 6 deletions src/build/arg/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
#[macro_use]
mod macros;
mod settings;
pub use self::settings::{ArgFlags, ArgSettings};

// Std
#[cfg(feature = "yaml")]
use std::collections::BTreeMap;
use std::rc::Rc;
use std::borrow::Cow;
use std::fmt::{self, Display, Formatter};
Expand All @@ -20,7 +16,7 @@ use std::str;

// Third Party
#[cfg(feature = "yaml")]
use yaml_rust::Yaml;
use yaml_rust;
use util::VecMap;

// Internal
Expand Down Expand Up @@ -157,7 +153,7 @@ impl<'a, 'b> Arg<'a, 'b> {
/// ```
/// [`Arg`]: ./struct.Arg.html
#[cfg(feature = "yaml")]
pub fn from_yaml(y: &BTreeMap<Yaml, Yaml>) -> Arg {
pub fn from_yaml(y: &yaml_rust::yaml::Hash) -> 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();
Expand Down
10 changes: 4 additions & 6 deletions src/build/arg_group/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// Std
#[cfg(feature = "yaml")]
use std::collections::BTreeMap;
use std::fmt::{Debug, Formatter, Result};

// Third Party
#[cfg(feature = "yaml")]
use yaml_rust::Yaml;
use yaml_rust;

/// `ArgGroup`s are a family of related [arguments] and way for you to express, "Any of these
/// arguments". By placing arguments in a logical group, you can create easier requirement and
Expand Down Expand Up @@ -131,7 +129,7 @@ impl<'a> ArgGroup<'a> {
/// # }
/// ```
#[cfg(feature = "yaml")]
pub fn from_yaml(y: &'a Yaml) -> ArgGroup<'a> { ArgGroup::from(y.as_hash().unwrap()) }
pub fn from_yaml(y: &'a yaml_rust::Yaml) -> ArgGroup<'a> { ArgGroup::from(y.as_hash().unwrap()) }

/// Adds an [argument] to this group by name
///
Expand Down Expand Up @@ -458,8 +456,8 @@ impl<'a, 'z> From<&'z ArgGroup<'a>> for ArgGroup<'a> {
}

#[cfg(feature = "yaml")]
impl<'a> From<&'a BTreeMap<Yaml, Yaml>> for ArgGroup<'a> {
fn from(b: &'a BTreeMap<Yaml, Yaml>) -> Self {
impl<'a> From<&'a yaml_rust::yaml::Hash> for ArgGroup<'a> {
fn from(b: &'a yaml_rust::yaml::Hash) -> Self {
// We WANT this to panic on error...so expect() is good.
let mut a = ArgGroup::default();
let group_settings = if b.len() == 1 {
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions src/build/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#[macro_use]
mod macros;

pub mod app;
pub mod arg;

Expand Down

0 comments on commit 8a7ac8f

Please sign in to comment.