Skip to content

Commit

Permalink
Auto merge of #830 - kbknapp:issue-826, r=kbknapp
Browse files Browse the repository at this point in the history
Issue 826
  • Loading branch information
homu committed Jan 30, 2017
2 parents c0bccaa + 8e2e744 commit 72d7bf3
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ language: rust
cache: cargo
rust:
- nightly
- nightly-2016-12-29
- nightly-2017-01-25
- beta
- stable
- 1.11.0
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
<a name="v2.20.1"></a>
### v2.20.1 (2017-01-30)

#### Bug Fixes

* Fix finding required arguments in group arguments ([f9f778e](https://github.com/kbknapp/clap-rs/commit/5b29be9b073330ab1f7227cdd19fe4aab39d5dcb), closes [#829](https://github.com/kbknapp/clap-rs/pull/829))

#### Documentation

* fix link from app_from_crate! to crate_authors! ([5b29be9b](https://github.com/kbknapp/clap-rs/commit/5b29be9b073330ab1f7227cdd19fe4aab39d5dcb), closes [#822](https://github.com/kbknapp/clap-rs/pull/822))
* fix spelling of "guaranteed" ([4f30a65b](https://github.com/kbknapp/clap-rs/commit/4f30a65b9c03eb09607eb91a929a6396637dc105))

#### Improvements

* updates libc and term_size deps for the libc version conflict ([6802ac4a](https://github.com/kbknapp/clap-rs/commit/6802ac4a59c142cda9ec55ca0c45ae5cb9a6ab55))

<a name="v2.20.0"></a>

#### New Settings
Expand Down
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

name = "clap"
version = "2.20.0"
version = "2.20.1"
authors = ["Kevin K. <kbknapp@gmail.com>"]
exclude = ["examples/*", "clap-test/*", "tests/*", "benches/*", "*.png", "clap-perf/*", "*.dot"]
repository = "https://github.com/kbknapp/clap-rs.git"
Expand All @@ -22,10 +22,10 @@ unicode-width = "0.1.4"
unicode-segmentation = "1.0.1"
strsim = { version = "0.6.0", optional = true }
ansi_term = { version = "0.9.0", optional = true }
term_size = { version = "0.2.1", optional = true }
libc = { version = "0.2.18", optional = true }
term_size = { version = "0.2.2", optional = true }
libc = { version = "0.2.20", optional = true }
yaml-rust = { version = "0.3.5", optional = true }
clippy = { version = "~0.0.104", optional = true }
clippy = { version = "~0.0.112", optional = true }

[dev-dependencies]
regex = "~0.1.80"
Expand Down
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,15 @@ Created by [gh-md-toc](https://github.com/ekalinin/github-markdown-toc)

## What's New

Here's the highlights for v2.20.0
Here's the highlights for v2.20.1

* updates libc and term_size deps for the libc version conflict
* Fix finding required arguments in group arguments
* fix link from app_from_crate! to crate_authors!
* fix spelling of "guaranteed"


Here's the highlights from v2.0.0 to v2.20.0

* **ArgsNegateSubcommands:** disables args being allowed between subcommands
* **DontCollapseArgsInUsage:** disables the collapsing of positional args into `[ARGS]` in the usage string
Expand All @@ -72,9 +80,6 @@ Here's the highlights for v2.20.0
* **Help Wrapping:** long app names (with spaces), authors, and descriptions are now wrapped appropriately
* **Conditional Default Values:** fixes the failing doc tests of Arg::default_value_ifs
* **Conditional Requirements:** adds docs for Arg::requires_ifs

Here's the highlights from v2.0.0 to v2.19.3

* Fixes a bug where calling the help of a subcommand wasn't ignoring required args of parent commands
* Fixes a bug by escaping square brackets in ZSH completions which were causing conflicts and errors.
* **Bash Completion:** allows bash completion to fall back to traidtional bash completion upon no matching completing function
Expand Down
28 changes: 14 additions & 14 deletions src/app/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ impl<'a> Help<'a> {
if first {
first = false;
} else {
try!(self.writer.write(b"\n"));
try!(self.writer.write_all(b"\n"));
}
try!(self.write_arg(arg.as_base()));
}
Expand Down Expand Up @@ -240,7 +240,7 @@ impl<'a> Help<'a> {
if first {
first = false;
} else {
try!(self.writer.write(b"\n"));
try!(self.writer.write_all(b"\n"));
}
try!(self.write_arg(arg.as_base()));
}
Expand Down Expand Up @@ -562,7 +562,7 @@ impl<'a> Help<'a> {
}
if opts {
if !first {
try!(self.writer.write(b"\n\n"));
try!(self.writer.write_all(b"\n\n"));
}
try!(color!(self, "OPTIONS:\n", warning));
try!(self.write_args(parser.opts().map(as_arg_trait)));
Expand All @@ -572,7 +572,7 @@ impl<'a> Help<'a> {

if pos {
if !first {
try!(self.writer.write(b"\n\n"));
try!(self.writer.write_all(b"\n\n"));
}
try!(color!(self, "ARGS:\n", warning));
try!(self.write_args_unsorted(parser.positionals().map(as_arg_trait)));
Expand All @@ -581,7 +581,7 @@ impl<'a> Help<'a> {

if subcmds {
if !first {
try!(self.writer.write(b"\n\n"));
try!(self.writer.write_all(b"\n\n"));
}
try!(color!(self, "SUBCOMMANDS:\n", warning));
try!(self.write_subcommands(&parser));
Expand All @@ -608,7 +608,7 @@ impl<'a> Help<'a> {
if first {
first = false;
} else {
try!(self.writer.write(b"\n"));
try!(self.writer.write_all(b"\n"));
}
try!(self.write_arg(sc));
}
Expand Down Expand Up @@ -653,7 +653,7 @@ impl<'a> Help<'a> {
debugln!("Help::write_default_help;");
if let Some(h) = parser.meta.pre_help {
try!(self.write_before_after_help(h));
try!(self.writer.write(b"\n\n"));
try!(self.writer.write_all(b"\n\n"));
}

macro_rules! write_thing {
Expand All @@ -667,9 +667,9 @@ impl<'a> Help<'a> {
}
// Print the version
try!(self.write_bin_name(&parser));
try!(self.writer.write(b" "));
try!(self.writer.write_all(b" "));
try!(self.write_version(&parser));
try!(self.writer.write(b"\n"));
try!(self.writer.write_all(b"\n"));
if let Some(author) = parser.meta.author {
write_thing!(author)
}
Expand All @@ -694,7 +694,7 @@ impl<'a> Help<'a> {

if let Some(h) = parser.meta.more_help {
if flags || opts || pos || subcmds {
try!(self.writer.write(b"\n\n"));
try!(self.writer.write_all(b"\n\n"));
}
try!(self.write_before_after_help(h));
}
Expand Down Expand Up @@ -857,7 +857,7 @@ impl<'a> Help<'a> {
});
match &tag_buf.get_ref()[0..tag_length] {
b"?" => {
try!(self.writer.write(b"Could not decode tag name"));
try!(self.writer.write_all(b"Could not decode tag name"));
}
b"bin" => {
try!(self.write_bin_name(&parser));
Expand Down Expand Up @@ -916,9 +916,9 @@ impl<'a> Help<'a> {
}
// Unknown tag, write it back.
r => {
try!(self.writer.write(b"{"));
try!(self.writer.write(r));
try!(self.writer.write(b"}"));
try!(self.writer.write_all(b"{"));
try!(self.writer.write_all(r));
try!(self.writer.write_all(b"}"));
}
}
}
Expand Down
21 changes: 11 additions & 10 deletions src/app/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,7 @@ impl<'a, 'b> Parser<'a, 'b>
} else if count == 1 {
let p = self.positionals
.values()
.filter(|p| !p.is_set(ArgSettings::Required))
.next()
.find(|p| !p.is_set(ArgSettings::Required))
.expect(INTERNAL_ERROR_MSG);
return Some(format!(" [{}]{}", p.name_no_brackets(), p.multiple_str()));
} else if self.is_set(AppSettings::DontCollapseArgsInUsage) &&
Expand Down Expand Up @@ -550,7 +549,7 @@ impl<'a, 'b> Parser<'a, 'b>
debug_assert!({
let mut it = self.positionals.values().rev();
// Either the final positional is required
it.next().unwrap().is_set(ArgSettings::Required)
it.next().unwrap().is_set(ArgSettings::Required)
// Or the second to last has a terminator set
|| it.next().unwrap().v.terminator.is_some()
},
Expand Down Expand Up @@ -723,6 +722,8 @@ impl<'a, 'b> Parser<'a, 'b>
sc._help()
}

// allow wrong self convention due to self.valid_neg_num = true and it's a private method
#[cfg_attr(feature = "lints", allow(wrong_self_convention))]
#[inline]
fn is_new_arg(&mut self, arg_os: &OsStr, needs_val_of: Option<&'a str>) -> bool {
debugln!("Parser::is_new_arg: arg={:?}, Needs Val of={:?}", arg_os, needs_val_of);
Expand Down Expand Up @@ -776,7 +777,7 @@ impl<'a, 'b> Parser<'a, 'b>
}

// The actual parsing function
#[cfg_attr(feature = "lints", allow(while_let_on_iterator))]
#[cfg_attr(feature = "lints", allow(while_let_on_iterator, collapsible_if))]
pub fn get_matches_with<I, T>(&mut self,
matcher: &mut ArgMatcher<'a>,
it: &mut Peekable<I>)
Expand Down Expand Up @@ -812,8 +813,8 @@ impl<'a, 'b> Parser<'a, 'b>
}
subcmd_name = Some(arg_os.to_str().expect(INVALID_UTF8).to_owned());
break;
}
}

if !starts_new_arg {
if let Some(name) = needs_val_of {
// Check to see if parsing a value from a previous arg
Expand Down Expand Up @@ -859,8 +860,8 @@ impl<'a, 'b> Parser<'a, 'b>
continue;
}
}
}
}

if !self.is_set(AppSettings::ArgsNegateSubcommands) {
if let Some(cdate) =
suggestions::did_you_mean(&*arg_os.to_string_lossy(),
Expand Down Expand Up @@ -1954,7 +1955,7 @@ impl<'a, 'b> Parser<'a, 'b>
usage.push_str(&*self.meta
.usage
.as_ref()
.unwrap_or(self.meta
.unwrap_or_else(|| self.meta
.bin_name
.as_ref()
.unwrap_or(&self.meta.name)));
Expand Down Expand Up @@ -2022,7 +2023,7 @@ impl<'a, 'b> Parser<'a, 'b>
usage.push_str(&self.meta
.usage
.as_ref()
.unwrap_or(self.meta
.unwrap_or_else(|| self.meta
.bin_name
.as_ref()
.unwrap_or(&self.meta
Expand Down
8 changes: 4 additions & 4 deletions src/app/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ bitflags! {
}

#[doc(hidden)]
#[derive(Debug, Copy)]
#[derive(Debug, Copy, Clone)]
pub struct AppFlags(Flags);

impl Clone for AppFlags {
fn clone(&self) -> Self { AppFlags(self.0) }
}
// impl Clone for AppFlags {
// fn clone(&self) -> Self { AppFlags(self.0) }
// }

impl BitOr for AppFlags {
type Output = Self;
Expand Down
4 changes: 2 additions & 2 deletions src/args/arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3208,7 +3208,7 @@ impl<'a, 'b, 'z> From<&'z Arg<'a, 'b>> for Arg<'a, 'b> {
disp_ord: a.disp_ord,
r_unless: a.r_unless.clone(),
r_ifs: a.r_ifs.clone(),
val_terminator: a.val_terminator.clone(),
val_terminator: a.val_terminator,
}
}
}
Expand Down Expand Up @@ -3240,7 +3240,7 @@ impl<'a, 'b> Clone for Arg<'a, 'b> {
disp_ord: self.disp_ord,
r_unless: self.r_unless.clone(),
r_ifs: self.r_ifs.clone(),
val_terminator: self.val_terminator.clone(),
val_terminator: self.val_terminator,
}
}
}
2 changes: 1 addition & 1 deletion src/args/arg_builder/valued.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl<'n, 'e, 'z> From<&'z Arg<'n, 'e>> for Valued<'n, 'e> {
val_delim: a.val_delim,
default_val: a.default_val,
default_vals_ifs: a.default_vals_ifs.clone(),
terminator: a.val_terminator.clone(),
terminator: a.val_terminator,
};
if let Some(ref vec) = a.val_names {
if vec.len() > 1 {
Expand Down
2 changes: 1 addition & 1 deletion src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ macro_rules! write_nspaces {
($dst:expr, $num:expr) => ({
debugln!("write_spaces!: num={}", $num);
for _ in 0..$num {
try!($dst.write(b" "));
try!($dst.write_all(b" "));
}
})
}
Expand Down

0 comments on commit 72d7bf3

Please sign in to comment.