mirror of
https://github.com/clap-rs/clap
synced 2025-03-04 23:37:32 +00:00
tests(Debugging): standardizes certain debugging calls
This commit is contained in:
parent
703b001d06
commit
0dcfc77dae
5 changed files with 21 additions and 15 deletions
|
@ -605,7 +605,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!("fn=write_subcommands;");
|
||||
let mut longest = 0;
|
||||
|
||||
let mut ord_m = VecMap::new();
|
||||
|
|
|
@ -88,6 +88,7 @@ macro_rules! _handle_group_reqs{
|
|||
} else {
|
||||
false
|
||||
};
|
||||
debugln!("iter;grp={};found={:?}", grp.name, found);
|
||||
if found {
|
||||
vec_remove_all!($me.required, &grp.args);
|
||||
debugln!("Adding args from group to blacklist...{:?}", grp.args);
|
||||
|
|
|
@ -439,7 +439,7 @@ impl<'a, 'b> Parser<'a, 'b>
|
|||
}
|
||||
|
||||
pub fn needs_flags_tag(&self) -> bool {
|
||||
debugln!("exec=needs_flags_tag;");
|
||||
debugln!("fn=needs_flags_tag;");
|
||||
'outer: for f in &self.flags {
|
||||
debugln!("iter;f={};", f.name);
|
||||
if let Some(l) = f.long {
|
||||
|
@ -763,7 +763,10 @@ impl<'a, 'b> Parser<'a, 'b>
|
|||
|
||||
let mut reqs_validated = false;
|
||||
if let Some(a) = needs_val_of {
|
||||
debugln!("needs_val_of={}", a);
|
||||
debug!("Is this an opt...");
|
||||
if let Some(o) = self.opts.iter().find(|o| &o.name == &a) {
|
||||
sdebugln!("Yes");
|
||||
try!(self.validate_required(matcher));
|
||||
reqs_validated = true;
|
||||
let should_err = if let Some(v) = matcher.0.args.get(&*o.name) {
|
||||
|
@ -777,6 +780,8 @@ impl<'a, 'b> Parser<'a, 'b>
|
|||
self.color()));
|
||||
}
|
||||
} else {
|
||||
sdebugln!("No");
|
||||
debugln!("Returning Error::empty_value");
|
||||
return Err(Error::empty_value(self.positionals
|
||||
.values()
|
||||
.find(|p| &p.name == &a)
|
||||
|
@ -846,7 +851,7 @@ impl<'a, 'b> Parser<'a, 'b>
|
|||
}
|
||||
|
||||
fn propogate_help_version(&mut self) {
|
||||
debugln!("exec=propogate_help_version;");
|
||||
debugln!("fn=propogate_help_version;");
|
||||
self.create_help_and_version();
|
||||
for sc in &mut self.subcommands {
|
||||
sc.p.propogate_help_version();
|
||||
|
@ -854,7 +859,7 @@ impl<'a, 'b> Parser<'a, 'b>
|
|||
}
|
||||
|
||||
fn build_bin_names(&mut self) {
|
||||
debugln!("exec=build_bin_names;");
|
||||
debugln!("fn=build_bin_names;");
|
||||
for sc in &mut self.subcommands {
|
||||
debug!("bin_name set...");
|
||||
if sc.p.meta.bin_name.is_none() {
|
||||
|
@ -992,7 +997,7 @@ impl<'a, 'b> Parser<'a, 'b>
|
|||
}
|
||||
|
||||
fn groups_for_arg(&self, name: &str) -> Option<Vec<&'a str>> {
|
||||
debugln!("fn=groups_for_arg;");
|
||||
debugln!("fn=groups_for_arg; name={}", name);
|
||||
|
||||
if self.groups.is_empty() {
|
||||
debugln!("No groups defined");
|
||||
|
@ -1149,14 +1154,14 @@ impl<'a, 'b> Parser<'a, 'b>
|
|||
fn check_for_help_and_version_char(&self, arg: char) -> ClapResult<()> {
|
||||
debug!("Checking if -{} is help or version...", arg);
|
||||
if let Some(h) = self.help_short {
|
||||
sdebugln!("Help");
|
||||
if arg == h && self.settings.is_set(AppSettings::NeedsLongHelp) {
|
||||
sdebugln!("Help");
|
||||
try!(self._help());
|
||||
}
|
||||
}
|
||||
if let Some(v) = self.version_short {
|
||||
sdebugln!("Help");
|
||||
if arg == v && self.settings.is_set(AppSettings::NeedsLongVersion) {
|
||||
sdebugln!("Version");
|
||||
try!(self._version());
|
||||
}
|
||||
}
|
||||
|
@ -1862,7 +1867,7 @@ impl<'a, 'b> Parser<'a, 'b>
|
|||
// Should we color the output? None=determined by output location, true=yes, false=no
|
||||
#[doc(hidden)]
|
||||
pub fn color(&self) -> ColorWhen {
|
||||
debugln!("exec=color;");
|
||||
debugln!("fn=color;");
|
||||
debug!("Color setting...");
|
||||
if self.is_set(AppSettings::ColorNever) {
|
||||
sdebugln!("Never");
|
||||
|
|
12
src/fmt.rs
12
src/fmt.rs
|
@ -28,7 +28,7 @@ pub enum ColorWhen {
|
|||
|
||||
#[cfg(feature = "color")]
|
||||
pub fn is_a_tty(stderr: bool) -> bool {
|
||||
debugln!("exec=is_a_tty;");
|
||||
debugln!("fn=is_a_tty;");
|
||||
debugln!("Use stderr...{:?}", stderr);
|
||||
let fd = if stderr { STDERR } else { STDOUT };
|
||||
unsafe { libc::isatty(fd) != 0 }
|
||||
|
@ -36,7 +36,7 @@ pub fn is_a_tty(stderr: bool) -> bool {
|
|||
|
||||
#[cfg(not(feature = "color"))]
|
||||
pub fn is_a_tty(_: bool) -> bool {
|
||||
debugln!("exec=is_a_tty;");
|
||||
debugln!("fn=is_a_tty;");
|
||||
false
|
||||
}
|
||||
|
||||
|
@ -64,28 +64,28 @@ impl Colorizer {
|
|||
pub fn good<T>(&self, msg: T) -> Format<T>
|
||||
where T: fmt::Display + AsRef<str>
|
||||
{
|
||||
debugln!("exec=good;");
|
||||
debugln!("fn=good;");
|
||||
color!(self, Good, msg)
|
||||
}
|
||||
|
||||
pub fn warning<T>(&self, msg: T) -> Format<T>
|
||||
where T: fmt::Display + AsRef<str>
|
||||
{
|
||||
debugln!("exec=warning;");
|
||||
debugln!("fn=warning;");
|
||||
color!(self, Warning, msg)
|
||||
}
|
||||
|
||||
pub fn error<T>(&self, msg: T) -> Format<T>
|
||||
where T: fmt::Display + AsRef<str>
|
||||
{
|
||||
debugln!("exec=error;");
|
||||
debugln!("fn=error;");
|
||||
color!(self, Error, msg)
|
||||
}
|
||||
|
||||
pub fn none<T>(&self, msg: T) -> Format<T>
|
||||
where T: fmt::Display + AsRef<str>
|
||||
{
|
||||
debugln!("exec=none;");
|
||||
debugln!("fn=none;");
|
||||
Format::None(msg)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ pub struct UsageParser<'a> {
|
|||
|
||||
impl<'a> UsageParser<'a> {
|
||||
fn new(usage: &'a str) -> Self {
|
||||
debugln!("exec=new; usage={:?}", usage);
|
||||
debugln!("fn=new; usage={:?}", usage);
|
||||
UsageParser {
|
||||
usage: usage,
|
||||
pos: 0,
|
||||
|
|
Loading…
Add table
Reference in a new issue