mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 23:02:31 +00:00
Merge #1810
1810: Remove {n} support r=CreepySkeleton a=pksunkara Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
This commit is contained in:
commit
7788268d37
6 changed files with 26 additions and 24 deletions
|
@ -43,6 +43,8 @@ stages:
|
||||||
displayName: Cache cargo
|
displayName: Cache cargo
|
||||||
- script: rustup default $(rust)-$(target)
|
- script: rustup default $(rust)-$(target)
|
||||||
displayName: Install rust
|
displayName: Install rust
|
||||||
|
- script: cargo test --no-default-features --features "std cargo" -p clap:3.0.0-beta.1
|
||||||
|
displayName: Test with almost no features
|
||||||
- script: cargo test --features "yaml unstable"
|
- script: cargo test --features "yaml unstable"
|
||||||
displayName: Test with most features
|
displayName: Test with most features
|
||||||
- script: |
|
- script: |
|
||||||
|
|
|
@ -58,6 +58,7 @@ jobs:
|
||||||
script:
|
script:
|
||||||
- cargo tarpaulin --workspace --features "yaml unstable" --ciserver travis-ci --coveralls $TRAVIS_JOB_ID --timeout 300
|
- cargo tarpaulin --workspace --features "yaml unstable" --ciserver travis-ci --coveralls $TRAVIS_JOB_ID --timeout 300
|
||||||
script:
|
script:
|
||||||
|
- cargo test --no-default-features --features "std cargo" -p clap:3.0.0-beta.1
|
||||||
- cargo test --features "yaml unstable"
|
- cargo test --features "yaml unstable"
|
||||||
notifications:
|
notifications:
|
||||||
email: false
|
email: false
|
||||||
|
|
|
@ -1291,11 +1291,11 @@ mod test {
|
||||||
#[test]
|
#[test]
|
||||||
fn pos_help_newline() {
|
fn pos_help_newline() {
|
||||||
let a = Arg::from(
|
let a = Arg::from(
|
||||||
"[pos]... 'some help{n}\
|
"[pos]... 'some help\n\
|
||||||
info'",
|
info'",
|
||||||
);
|
);
|
||||||
assert_eq!(a.name, "pos");
|
assert_eq!(a.name, "pos");
|
||||||
assert_eq!(a.help.unwrap(), "some help{n}info");
|
assert_eq!(a.help.unwrap(), "some help\ninfo");
|
||||||
assert!(
|
assert!(
|
||||||
a.is_set(ArgSettings::MultipleValues) && a.is_set(ArgSettings::MultipleOccurrences)
|
a.is_set(ArgSettings::MultipleValues) && a.is_set(ArgSettings::MultipleOccurrences)
|
||||||
);
|
);
|
||||||
|
@ -1307,11 +1307,11 @@ mod test {
|
||||||
#[test]
|
#[test]
|
||||||
fn pos_help_newline_lit_sq() {
|
fn pos_help_newline_lit_sq() {
|
||||||
let a = Arg::from(
|
let a = Arg::from(
|
||||||
"[pos]... 'some help\' stuff{n}\
|
"[pos]... 'some help\' stuff\n\
|
||||||
info'",
|
info'",
|
||||||
);
|
);
|
||||||
assert_eq!(a.name, "pos");
|
assert_eq!(a.name, "pos");
|
||||||
assert_eq!(a.help.unwrap(), "some help' stuff{n}info");
|
assert_eq!(a.help.unwrap(), "some help' stuff\ninfo");
|
||||||
assert!(
|
assert!(
|
||||||
a.is_set(ArgSettings::MultipleValues) && a.is_set(ArgSettings::MultipleOccurrences)
|
a.is_set(ArgSettings::MultipleValues) && a.is_set(ArgSettings::MultipleOccurrences)
|
||||||
);
|
);
|
||||||
|
|
|
@ -359,7 +359,7 @@ impl<'b, 'c, 'd, 'w> Help<'b, 'c, 'd, 'w> {
|
||||||
let too_long = str_width(h) >= self.term_w;
|
let too_long = str_width(h) >= self.term_w;
|
||||||
|
|
||||||
debug!("Help::write_before_after_help: Too long...");
|
debug!("Help::write_before_after_help: Too long...");
|
||||||
if too_long || h.contains("{n}") {
|
if too_long {
|
||||||
sdebugln!("Yes");
|
sdebugln!("Yes");
|
||||||
debugln!("Help::write_before_after_help: help: {}", help);
|
debugln!("Help::write_before_after_help: help: {}", help);
|
||||||
debugln!(
|
debugln!(
|
||||||
|
@ -371,7 +371,7 @@ impl<'b, 'c, 'd, 'w> Help<'b, 'c, 'd, 'w> {
|
||||||
"Help::write_before_after_help: Usable space: {}",
|
"Help::write_before_after_help: Usable space: {}",
|
||||||
self.term_w
|
self.term_w
|
||||||
);
|
);
|
||||||
help = wrap_help(&help.replace("{n}", "\n"), self.term_w);
|
help = wrap_help(&help, self.term_w);
|
||||||
} else {
|
} else {
|
||||||
sdebugln!("No");
|
sdebugln!("No");
|
||||||
}
|
}
|
||||||
|
@ -405,14 +405,14 @@ impl<'b, 'c, 'd, 'w> Help<'b, 'c, 'd, 'w> {
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("Help::help: Too long...");
|
debug!("Help::help: Too long...");
|
||||||
if too_long && spcs <= self.term_w || h.contains("{n}") {
|
if too_long && spcs <= self.term_w {
|
||||||
sdebugln!("Yes");
|
sdebugln!("Yes");
|
||||||
debugln!("Help::help: help...{}", help);
|
debugln!("Help::help: help...{}", help);
|
||||||
debugln!("Help::help: help width...{}", str_width(&*help));
|
debugln!("Help::help: help width...{}", str_width(&*help));
|
||||||
// Determine how many newlines we need to insert
|
// Determine how many newlines we need to insert
|
||||||
let avail_chars = self.term_w - spcs;
|
let avail_chars = self.term_w - spcs;
|
||||||
debugln!("Help::help: Usable space...{}", avail_chars);
|
debugln!("Help::help: Usable space...{}", avail_chars);
|
||||||
help = wrap_help(&help.replace("{n}", "\n"), avail_chars);
|
help = wrap_help(&help, avail_chars);
|
||||||
} else {
|
} else {
|
||||||
sdebugln!("No");
|
sdebugln!("No");
|
||||||
}
|
}
|
||||||
|
@ -601,14 +601,14 @@ impl<'b, 'c, 'd, 'w> Help<'b, 'c, 'd, 'w> {
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("Help::sc_help: Too long...");
|
debug!("Help::sc_help: Too long...");
|
||||||
if too_long && spcs <= self.term_w || h.contains("{n}") {
|
if too_long && spcs <= self.term_w {
|
||||||
sdebugln!("Yes");
|
sdebugln!("Yes");
|
||||||
debugln!("Help::sc_help: help...{}", help);
|
debugln!("Help::sc_help: help...{}", help);
|
||||||
debugln!("Help::sc_help: help width...{}", str_width(&*help));
|
debugln!("Help::sc_help: help width...{}", str_width(&*help));
|
||||||
// Determine how many newlines we need to insert
|
// Determine how many newlines we need to insert
|
||||||
let avail_chars = self.term_w - spcs;
|
let avail_chars = self.term_w - spcs;
|
||||||
debugln!("Help::sc_help: Usable space...{}", avail_chars);
|
debugln!("Help::sc_help: Usable space...{}", avail_chars);
|
||||||
help = wrap_help(&help.replace("{n}", "\n"), avail_chars);
|
help = wrap_help(&help, avail_chars);
|
||||||
} else {
|
} else {
|
||||||
sdebugln!("No");
|
sdebugln!("No");
|
||||||
}
|
}
|
||||||
|
@ -784,10 +784,7 @@ impl<'b, 'c, 'd, 'w> Help<'b, 'c, 'd, 'w> {
|
||||||
let term_w = self.term_w;
|
let term_w = self.term_w;
|
||||||
macro_rules! write_name {
|
macro_rules! write_name {
|
||||||
() => {{
|
() => {{
|
||||||
self.color(Format::Good(&*wrap_help(
|
self.color(Format::Good(&*wrap_help(&self.parser.app.name, term_w)))?;
|
||||||
&self.parser.app.name.replace("{n}", "\n"),
|
|
||||||
term_w,
|
|
||||||
)))?;
|
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
if let Some(bn) = self.parser.app.bin_name.as_ref() {
|
if let Some(bn) = self.parser.app.bin_name.as_ref() {
|
||||||
|
@ -813,11 +810,7 @@ impl<'b, 'c, 'd, 'w> Help<'b, 'c, 'd, 'w> {
|
||||||
|
|
||||||
macro_rules! write_thing {
|
macro_rules! write_thing {
|
||||||
($thing:expr) => {{
|
($thing:expr) => {{
|
||||||
write!(
|
write!(self.writer, "{}\n", wrap_help(&$thing, self.term_w))?
|
||||||
self.writer,
|
|
||||||
"{}\n",
|
|
||||||
wrap_help(&$thing.replace("{n}", "\n"), self.term_w)
|
|
||||||
)?
|
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
// Print the version
|
// Print the version
|
||||||
|
|
|
@ -876,9 +876,9 @@ fn wrapping_newline_chars() {
|
||||||
.version("0.1")
|
.version("0.1")
|
||||||
.set_term_width(60)
|
.set_term_width(60)
|
||||||
.arg(Arg::with_name("mode").help(
|
.arg(Arg::with_name("mode").help(
|
||||||
"x, max, maximum 20 characters, contains symbols.{n}\
|
"x, max, maximum 20 characters, contains symbols.\n\
|
||||||
l, long Copy-friendly, 14 characters, contains symbols.{n}\
|
l, long Copy-friendly, 14 characters, contains symbols.\n\
|
||||||
m, med, medium Copy-friendly, 8 characters, contains symbols.{n}",
|
m, med, medium Copy-friendly, 8 characters, contains symbols.\n",
|
||||||
));
|
));
|
||||||
assert!(utils::compare_output(
|
assert!(utils::compare_output(
|
||||||
app,
|
app,
|
||||||
|
@ -893,7 +893,7 @@ fn old_newline_chars() {
|
||||||
let app = App::new("ctest").version("0.1").arg(
|
let app = App::new("ctest").version("0.1").arg(
|
||||||
Arg::with_name("mode")
|
Arg::with_name("mode")
|
||||||
.short('m')
|
.short('m')
|
||||||
.help("Some help with some wrapping{n}(Defaults to something)"),
|
.help("Some help with some wrapping\n(Defaults to something)"),
|
||||||
);
|
);
|
||||||
assert!(utils::compare_output(
|
assert!(utils::compare_output(
|
||||||
app,
|
app,
|
||||||
|
|
|
@ -54,7 +54,13 @@ pub fn compare_output2(l: App, args: &str, right1: &str, right2: &str, stderr: b
|
||||||
err.write_to(&mut buf).unwrap();
|
err.write_to(&mut buf).unwrap();
|
||||||
let content = buf.into_inner();
|
let content = buf.into_inner();
|
||||||
let left = String::from_utf8(content).unwrap();
|
let left = String::from_utf8(content).unwrap();
|
||||||
assert_eq!(stderr, err.use_stderr());
|
assert_eq!(
|
||||||
|
stderr,
|
||||||
|
err.use_stderr(),
|
||||||
|
"Should Use STDERR failed. Should be {} but is {}",
|
||||||
|
stderr,
|
||||||
|
err.use_stderr()
|
||||||
|
);
|
||||||
compare(&*left, right1) || compare(&*left, right2)
|
compare(&*left, right1) || compare(&*left, right2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue