Skip to content

Commit

Permalink
Auto merge of #524 - kbknapp:issues-511,523, r=kbknapp
Browse files Browse the repository at this point in the history
Issues 511,523
  • Loading branch information
homu committed Jun 8, 2016
2 parents a77c800 + d0fd55a commit e1d33f8
Show file tree
Hide file tree
Showing 10 changed files with 157 additions and 222 deletions.
147 changes: 0 additions & 147 deletions '

This file was deleted.

2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ sudo: false
language: rust
rust:
- nightly
- nightly-2016-04-28
- nightly-2016-06-05
- beta
- stable
# Only while clippy is failing
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ libc = { version = "~0.2.9", optional = true }
ansi_term = { version = "~0.7.2", optional = true }
strsim = { version = "~0.4.0", optional = true }
yaml-rust = { version = "~0.3.2", optional = true }
clippy = { version = "=0.0.64", optional = true }
clippy = { version = "~0.0.74", optional = true }
unicode-width = { version = "~0.1.3", optional = true }

[dev-dependencies]
Expand Down
7 changes: 3 additions & 4 deletions src/app/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl<'a> Help<'a> {
use_stderr: stderr,
when: parser.color(),
};
Self::new(w, nlh, hide_v, color, cizer).write_help(&parser)
Self::new(w, nlh, hide_v, color, cizer).write_help(parser)
}

/// Writes the parser help to the wrapped stream.
Expand Down Expand Up @@ -485,6 +485,7 @@ impl<'a> Help<'a> {
impl<'a> Help<'a> {
/// Writes help for all arguments (options, flags, args, subcommands)
/// including titles of a Parser Object to the wrapped stream.
#[cfg_attr(feature = "lints", allow(useless_let_if_seq))]
pub fn write_all_args(&mut self, parser: &Parser) -> ClapResult<()> {

let flags = parser.has_flags();
Expand Down Expand Up @@ -542,7 +543,7 @@ impl<'a> Help<'a> {

/// Writes help for subcommands of a Parser Object to the wrapped stream.
fn write_subcommands(&mut self, parser: &Parser) -> io::Result<()> {
debugln!("exec=write_subcommands;");
debugln!("exec=write_subcommands;");
let mut longest = 0;

let mut ord_m = VecMap::new();
Expand All @@ -556,12 +557,10 @@ impl<'a> Help<'a> {
for (_, btm) in ord_m.into_iter() {
for (_, sc) in btm.into_iter() {
if !first {
debugln!("Writing newline...");
try!(self.writer.write(b"\n"));
} else {
first = false;
}
debugln!("Writing sc...{}", sc);
try!(self.write_arg(sc, longest));
}
}
Expand Down
22 changes: 11 additions & 11 deletions src/app/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,18 @@ macro_rules! _handle_group_reqs{
use args::AnyArg;
debugln!("macro=_handle_group_reqs!;");
for grp in $me.groups.values() {
let mut found = false;
if grp.args.contains(&$arg.name()) {
let found = if grp.args.contains(&$arg.name()) {
vec_remove!($me.required, &$arg.name());
if let Some(ref reqs) = grp.requires {
$me.required.extend(reqs);
}
if let Some(ref bl) = grp.conflicts {
$me.blacklist.extend(bl);
}
found = true; // What if arg is in more than one group with different reqs?
}
true // What if arg is in more than one group with different reqs?
} else {
false
};
if found {
vec_remove_all!($me.required, &grp.args);
debugln!("Adding args from group to blacklist...{:?}", grp.args);
Expand All @@ -112,27 +113,26 @@ macro_rules! parse_positional {
$_self:ident,
$p:ident,
$arg_os:ident,
$pos_only:ident,
$pos_counter:ident,
$matcher:ident
) => {
debugln!("macro=parse_positional!;");
validate_multiples!($_self, $p, $matcher);

if let Err(e) = $_self.add_val_to_arg($p, &$arg_os, $matcher) {
return Err(e);
}
if !$pos_only &&
if !$_self.trailing_vals &&
($_self.settings.is_set(AppSettings::TrailingVarArg) &&
$pos_counter == $_self.positionals.len()) {
$pos_only = true;
$_self.trailing_vals = true;
}
if let Err(e) = $_self.add_val_to_arg($p, &$arg_os, $matcher) {
return Err(e);
}

$matcher.inc_occurrence_of($p.name);
let _ = $_self.groups_for_arg($p.name)
.and_then(|vec| Some($matcher.inc_occurrences_of(&*vec)));
arg_post_processing!($_self, $p, $matcher);
// Only increment the positional counter if it doesn't allow multiples
// Only increment the positional counter if it doesn't allow multiples
if !$p.settings.is_set(ArgSettings::Multiple) {
$pos_counter += 1;
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ impl<'a, 'b> App<'a, 'b> {
/// ```
/// [`io::Write`]: https://doc.rust-lang.org/std/io/trait.Write.html
pub fn write_help<W: Write>(&self, w: &mut W) -> ClapResult<()> {
Help::write_app_help(w, &self)
Help::write_app_help(w, self)
}

/// Writes the version message to the user to a [`io::Write`] object
Expand Down
Loading

0 comments on commit e1d33f8

Please sign in to comment.