Skip to content

Commit 0dcfc77

Browse files
committed
tests(Debugging): standardizes certain debugging calls
1 parent 703b001 commit 0dcfc77

File tree

5 files changed

+21
-15
lines changed

5 files changed

+21
-15
lines changed

src/app/help.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ impl<'a> Help<'a> {
605605

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

611611
let mut ord_m = VecMap::new();

src/app/macros.rs

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ macro_rules! _handle_group_reqs{
8888
} else {
8989
false
9090
};
91+
debugln!("iter;grp={};found={:?}", grp.name, found);
9192
if found {
9293
vec_remove_all!($me.required, &grp.args);
9394
debugln!("Adding args from group to blacklist...{:?}", grp.args);

src/app/parser.rs

+12-7
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ impl<'a, 'b> Parser<'a, 'b>
439439
}
440440

441441
pub fn needs_flags_tag(&self) -> bool {
442-
debugln!("exec=needs_flags_tag;");
442+
debugln!("fn=needs_flags_tag;");
443443
'outer: for f in &self.flags {
444444
debugln!("iter;f={};", f.name);
445445
if let Some(l) = f.long {
@@ -763,7 +763,10 @@ impl<'a, 'b> Parser<'a, 'b>
763763

764764
let mut reqs_validated = false;
765765
if let Some(a) = needs_val_of {
766+
debugln!("needs_val_of={}", a);
767+
debug!("Is this an opt...");
766768
if let Some(o) = self.opts.iter().find(|o| &o.name == &a) {
769+
sdebugln!("Yes");
767770
try!(self.validate_required(matcher));
768771
reqs_validated = true;
769772
let should_err = if let Some(v) = matcher.0.args.get(&*o.name) {
@@ -777,6 +780,8 @@ impl<'a, 'b> Parser<'a, 'b>
777780
self.color()));
778781
}
779782
} else {
783+
sdebugln!("No");
784+
debugln!("Returning Error::empty_value");
780785
return Err(Error::empty_value(self.positionals
781786
.values()
782787
.find(|p| &p.name == &a)
@@ -846,15 +851,15 @@ impl<'a, 'b> Parser<'a, 'b>
846851
}
847852

848853
fn propogate_help_version(&mut self) {
849-
debugln!("exec=propogate_help_version;");
854+
debugln!("fn=propogate_help_version;");
850855
self.create_help_and_version();
851856
for sc in &mut self.subcommands {
852857
sc.p.propogate_help_version();
853858
}
854859
}
855860

856861
fn build_bin_names(&mut self) {
857-
debugln!("exec=build_bin_names;");
862+
debugln!("fn=build_bin_names;");
858863
for sc in &mut self.subcommands {
859864
debug!("bin_name set...");
860865
if sc.p.meta.bin_name.is_none() {
@@ -992,7 +997,7 @@ impl<'a, 'b> Parser<'a, 'b>
992997
}
993998

994999
fn groups_for_arg(&self, name: &str) -> Option<Vec<&'a str>> {
995-
debugln!("fn=groups_for_arg;");
1000+
debugln!("fn=groups_for_arg; name={}", name);
9961001

9971002
if self.groups.is_empty() {
9981003
debugln!("No groups defined");
@@ -1149,14 +1154,14 @@ impl<'a, 'b> Parser<'a, 'b>
11491154
fn check_for_help_and_version_char(&self, arg: char) -> ClapResult<()> {
11501155
debug!("Checking if -{} is help or version...", arg);
11511156
if let Some(h) = self.help_short {
1152-
sdebugln!("Help");
11531157
if arg == h && self.settings.is_set(AppSettings::NeedsLongHelp) {
1158+
sdebugln!("Help");
11541159
try!(self._help());
11551160
}
11561161
}
11571162
if let Some(v) = self.version_short {
1158-
sdebugln!("Help");
11591163
if arg == v && self.settings.is_set(AppSettings::NeedsLongVersion) {
1164+
sdebugln!("Version");
11601165
try!(self._version());
11611166
}
11621167
}
@@ -1862,7 +1867,7 @@ impl<'a, 'b> Parser<'a, 'b>
18621867
// Should we color the output? None=determined by output location, true=yes, false=no
18631868
#[doc(hidden)]
18641869
pub fn color(&self) -> ColorWhen {
1865-
debugln!("exec=color;");
1870+
debugln!("fn=color;");
18661871
debug!("Color setting...");
18671872
if self.is_set(AppSettings::ColorNever) {
18681873
sdebugln!("Never");

src/fmt.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ pub enum ColorWhen {
2828

2929
#[cfg(feature = "color")]
3030
pub fn is_a_tty(stderr: bool) -> bool {
31-
debugln!("exec=is_a_tty;");
31+
debugln!("fn=is_a_tty;");
3232
debugln!("Use stderr...{:?}", stderr);
3333
let fd = if stderr { STDERR } else { STDOUT };
3434
unsafe { libc::isatty(fd) != 0 }
3535
}
3636

3737
#[cfg(not(feature = "color"))]
3838
pub fn is_a_tty(_: bool) -> bool {
39-
debugln!("exec=is_a_tty;");
39+
debugln!("fn=is_a_tty;");
4040
false
4141
}
4242

@@ -64,28 +64,28 @@ impl Colorizer {
6464
pub fn good<T>(&self, msg: T) -> Format<T>
6565
where T: fmt::Display + AsRef<str>
6666
{
67-
debugln!("exec=good;");
67+
debugln!("fn=good;");
6868
color!(self, Good, msg)
6969
}
7070

7171
pub fn warning<T>(&self, msg: T) -> Format<T>
7272
where T: fmt::Display + AsRef<str>
7373
{
74-
debugln!("exec=warning;");
74+
debugln!("fn=warning;");
7575
color!(self, Warning, msg)
7676
}
7777

7878
pub fn error<T>(&self, msg: T) -> Format<T>
7979
where T: fmt::Display + AsRef<str>
8080
{
81-
debugln!("exec=error;");
81+
debugln!("fn=error;");
8282
color!(self, Error, msg)
8383
}
8484

8585
pub fn none<T>(&self, msg: T) -> Format<T>
8686
where T: fmt::Display + AsRef<str>
8787
{
88-
debugln!("exec=none;");
88+
debugln!("fn=none;");
8989
Format::None(msg)
9090
}
9191
}

src/usage_parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub struct UsageParser<'a> {
3131

3232
impl<'a> UsageParser<'a> {
3333
fn new(usage: &'a str) -> Self {
34-
debugln!("exec=new; usage={:?}", usage);
34+
debugln!("fn=new; usage={:?}", usage);
3535
UsageParser {
3636
usage: usage,
3737
pos: 0,

0 commit comments

Comments
 (0)