Skip to content

Commit

Permalink
Correct misrebase
Browse files Browse the repository at this point in the history
  • Loading branch information
CreepySkeleton committed Aug 22, 2020
1 parent ba087e7 commit ca9f300
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/output/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ impl<'help, 'app, 'parser, 'writer> Help<'help, 'app, 'parser, 'writer> {
/// For details about the template language see [`App::help_template`].
///
/// [`App::help_template`]: ./struct.App.html#method.help_template
fn write_templated_help(&mut self, template: &str) -> ClapResult<()> {
fn write_templated_help(&mut self, template: &str) -> io::Result<()> {
debug!("Help::write_templated_help");

// The strategy is to copy the template from the reader to wrapped stream
Expand Down
4 changes: 2 additions & 2 deletions src/output/usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ impl<'help, 'app, 'parser> Usage<'help, 'app, 'parser> {
.map(|pos| format!(" [{}]{}", pos.name_no_brackets(), pos.multiple_str()))
.collect::<Vec<_>>()
.join(""),
);
)
} else if !incl_reqs {
debug!("Usage::get_args_tag:iter: incl_reqs=false, building secondary usage string");
let highest_req_pos = self
Expand All @@ -311,7 +311,7 @@ impl<'help, 'app, 'parser> Usage<'help, 'app, 'parser> {
.map(|pos| format!(" [{}]{}", pos.name_no_brackets(), pos.multiple_str()))
.collect::<Vec<_>>()
.join(""),
);
)
} else {
Some("".into())
}
Expand Down
7 changes: 1 addition & 6 deletions src/parse/matches/arg_matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,7 @@ impl ArgMatches {
v, name, e
);

Error::value_validation(
name.to_string(),
v.to_string(),
message,
ColorChoice::Auto,
)
Error::value_validation(name.to_string(), v.to_string(), message, ColorChoice::Auto)
})
} else {
Err(Error::argument_not_found_auto(name))
Expand Down
2 changes: 1 addition & 1 deletion src/parse/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
debug!("error");
return Err(Error::value_validation(
arg.to_string(),
val,
val.to_string_lossy().to_string(),
e,
self.p.app.color(),
));
Expand Down
4 changes: 2 additions & 2 deletions tests/conflicts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ fn two_conflicting_arguments() {
let a = a.unwrap_err();
assert!(
a.to_string()
.contains("The argument \'--develop\' cannot be used with \'--production\'"),
.contains("The argument \'--production\' cannot be used with \'--develop\'"),
"{}",
a
);
Expand Down Expand Up @@ -220,7 +220,7 @@ fn three_conflicting_arguments() {
let a = a.unwrap_err();
assert!(
a.to_string()
.contains("The argument \'--one\' cannot be used with \'--two\'"),
.contains("The argument \'--two\' cannot be used with \'--one\'"),
"{}",
a
);
Expand Down
40 changes: 36 additions & 4 deletions tests/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,10 +608,6 @@ fn setup() -> App<'static> {
.version("1.3")
}

fn empty_args() -> impl IntoIterator<Item = String> {
std::iter::empty()
}

#[test]
fn help_short() {
let m = setup().try_get_matches_from(vec!["myprog", "-h"]);
Expand Down Expand Up @@ -1789,3 +1785,39 @@ fn help_required_and_no_args() {
.setting(AppSettings::HelpRequired)
.get_matches_from(&["test"]);
}

#[test]
fn issue_1642_long_help_spacing() {
let app = App::new("prog").arg(Arg::new("cfg").long("config").long_about(
"The config file used by the myprog must be in JSON format
with only valid keys and may not contain other nonsense
that cannot be read by this program. Obviously I'm going on
and on, so I'll stop now.",
));
assert!(utils::compare_output(app, "prog --help", ISSUE_1642, false));
}

const AFTER_HELP_NO_ARGS: &str = "myapp 1.0
USAGE:
myapp
This is after help.
";

#[test]
fn after_help_no_args() {
let mut app = App::new("myapp")
.version("1.0")
.setting(AppSettings::DisableHelpFlags)
.setting(AppSettings::DisableVersion)
.after_help("This is after help.");

let help = {
let mut output = Vec::new();
app.write_help(&mut output).unwrap();
String::from_utf8(output).unwrap()
};

assert_eq!(help, AFTER_HELP_NO_ARGS);
}

0 comments on commit ca9f300

Please sign in to comment.