Skip to content

Commit

Permalink
chore: Rename App::color to App::get_color
Browse files Browse the repository at this point in the history
  • Loading branch information
pksunkara committed Oct 11, 2021
1 parent 562e64c commit 937d76a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
6 changes: 3 additions & 3 deletions src/build/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1788,7 +1788,7 @@ impl<'help> App<'help> {
/// [`--help` (long)]: Arg::long_about()
pub fn print_help(&mut self) -> io::Result<()> {
self._build();
let color = self.color();
let color = self.get_color();

let p = Parser::new(self);
let mut c = Colorizer::new(false, color);
Expand All @@ -1815,7 +1815,7 @@ impl<'help> App<'help> {
/// [`--help` (long)]: Arg::long_about()
pub fn print_long_help(&mut self) -> io::Result<()> {
self._build();
let color = self.color();
let color = self.get_color();

let p = Parser::new(self);
let mut c = Colorizer::new(false, color);
Expand Down Expand Up @@ -2647,7 +2647,7 @@ impl<'help> App<'help> {

#[inline]
// Should we color the output?
pub(crate) fn color(&self) -> ColorChoice {
pub(crate) fn get_color(&self) -> ColorChoice {
debug!("App::color: Color setting...");

if self.is_set(AppSettings::ColorNever) {
Expand Down
1 change: 0 additions & 1 deletion src/build/app/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ bitflags! {
const NO_POS_VALUES = 1 << 17;
const NEXT_LINE_HELP = 1 << 18;
const DERIVE_DISP_ORDER = 1 << 19;
const COLORED_HELP = 1 << 20;
const COLOR_ALWAYS = 1 << 21;
const COLOR_AUTO = 1 << 22;
const COLOR_NEVER = 1 << 23;
Expand Down
34 changes: 17 additions & 17 deletions src/parse/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ impl Error {
other: Option<String>,
usage: String,
) -> Self {
let mut c = Colorizer::new(true, app.color());
let mut c = Colorizer::new(true, app.get_color());
let arg = arg.to_string();

start_error(&mut c, "The argument '");
Expand Down Expand Up @@ -584,7 +584,7 @@ impl Error {
}

pub(crate) fn empty_value(app: &App, arg: &Arg, usage: String) -> Self {
let mut c = Colorizer::new(true, app.color());
let mut c = Colorizer::new(true, app.get_color());
let arg = arg.to_string();

start_error(&mut c, "The argument '");
Expand All @@ -603,7 +603,7 @@ impl Error {
}

pub(crate) fn no_equals(app: &App, arg: String, usage: String) -> Self {
let mut c = Colorizer::new(true, app.color());
let mut c = Colorizer::new(true, app.get_color());

start_error(&mut c, "Equal sign is needed when assigning values to '");
c.warning(&arg);
Expand Down Expand Up @@ -631,7 +631,7 @@ impl Error {
where
G: AsRef<str> + Display,
{
let mut c = Colorizer::new(true, app.color());
let mut c = Colorizer::new(true, app.get_color());
let suffix = suggestions::did_you_mean(&bad_val, good_vals.iter()).pop();

let mut sorted: Vec<String> = good_vals
Expand Down Expand Up @@ -692,7 +692,7 @@ impl Error {
name: String,
usage: String,
) -> Self {
let mut c = Colorizer::new(true, app.color());
let mut c = Colorizer::new(true, app.get_color());

start_error(&mut c, "The subcommand '");
c.warning(subcmd.clone());
Expand All @@ -718,7 +718,7 @@ impl Error {
}

pub(crate) fn unrecognized_subcommand(app: &App, subcmd: String, name: String) -> Self {
let mut c = Colorizer::new(true, app.color());
let mut c = Colorizer::new(true, app.get_color());

start_error(&mut c, " The subcommand '");
c.warning(subcmd.clone());
Expand All @@ -741,7 +741,7 @@ impl Error {
required: Vec<String>,
usage: String,
) -> Self {
let mut c = Colorizer::new(true, app.color());
let mut c = Colorizer::new(true, app.get_color());

start_error(
&mut c,
Expand All @@ -768,7 +768,7 @@ impl Error {
}

pub(crate) fn missing_subcommand(app: &App, name: String, usage: String) -> Self {
let mut c = Colorizer::new(true, app.color());
let mut c = Colorizer::new(true, app.get_color());

start_error(&mut c, "'");
c.warning(name);
Expand All @@ -786,7 +786,7 @@ impl Error {
}

pub(crate) fn invalid_utf8(app: &App, usage: String) -> Self {
let mut c = Colorizer::new(true, app.color());
let mut c = Colorizer::new(true, app.get_color());

start_error(
&mut c,
Expand All @@ -811,7 +811,7 @@ impl Error {
curr_occurs: usize,
usage: String,
) -> Self {
let mut c = Colorizer::new(true, app.color());
let mut c = Colorizer::new(true, app.get_color());
let verb = Error::singular_or_plural(curr_occurs);

start_error(&mut c, "The argument '");
Expand All @@ -838,7 +838,7 @@ impl Error {
}

pub(crate) fn too_many_values(app: &App, val: String, arg: String, usage: String) -> Self {
let mut c = Colorizer::new(true, app.color());
let mut c = Colorizer::new(true, app.get_color());

start_error(&mut c, "The value '");
c.warning(val.clone());
Expand All @@ -864,7 +864,7 @@ impl Error {
curr_vals: usize,
usage: String,
) -> Self {
let mut c = Colorizer::new(true, app.color());
let mut c = Colorizer::new(true, app.get_color());
let verb = Error::singular_or_plural(curr_vals);

start_error(&mut c, "The argument '");
Expand Down Expand Up @@ -898,7 +898,7 @@ impl Error {
info,
source,
backtrace,
} = Self::value_validation_with_color(arg, val, err, app.color());
} = Self::value_validation_with_color(arg, val, err, app.get_color());
try_help(app, &mut message);
Self {
message,
Expand Down Expand Up @@ -949,7 +949,7 @@ impl Error {
curr_vals: usize,
usage: String,
) -> Self {
let mut c = Colorizer::new(true, app.color());
let mut c = Colorizer::new(true, app.get_color());
let verb = Error::singular_or_plural(curr_vals);

start_error(&mut c, "The argument '");
Expand All @@ -972,7 +972,7 @@ impl Error {
}

pub(crate) fn unexpected_multiple_usage(app: &App, arg: &Arg, usage: String) -> Self {
let mut c = Colorizer::new(true, app.color());
let mut c = Colorizer::new(true, app.get_color());
let arg = arg.to_string();

start_error(&mut c, "The argument '");
Expand All @@ -996,7 +996,7 @@ impl Error {
did_you_mean: Option<(String, Option<String>)>,
usage: String,
) -> Self {
let mut c = Colorizer::new(true, app.color());
let mut c = Colorizer::new(true, app.get_color());

start_error(&mut c, "Found argument '");
c.warning(arg.clone());
Expand Down Expand Up @@ -1041,7 +1041,7 @@ impl Error {
}

pub(crate) fn unnecessary_double_dash(app: &App, arg: String, usage: String) -> Self {
let mut c = Colorizer::new(true, app.color());
let mut c = Colorizer::new(true, app.get_color());

start_error(&mut c, "Found argument '");
c.warning(arg.clone());
Expand Down
6 changes: 3 additions & 3 deletions src/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1874,7 +1874,7 @@ impl<'help, 'app> Parser<'help, 'app> {
}

pub(crate) fn write_help_err(&self) -> ClapResult<Colorizer> {
let mut c = Colorizer::new(true, self.app.color());
let mut c = Colorizer::new(true, self.app.get_color());
Help::new(HelpWriter::Buffer(&mut c), self, false).write_help()?;
Ok(c)
}
Expand All @@ -1886,7 +1886,7 @@ impl<'help, 'app> Parser<'help, 'app> {
);

use_long = use_long && self.use_long_help();
let mut c = Colorizer::new(false, self.app.color());
let mut c = Colorizer::new(false, self.app.get_color());

match Help::new(HelpWriter::Buffer(&mut c), self, use_long).write_help() {
Err(e) => e.into(),
Expand All @@ -1898,7 +1898,7 @@ impl<'help, 'app> Parser<'help, 'app> {
debug!("Parser::version_err");

let msg = self.app._render_version(use_long);
let mut c = Colorizer::new(false, self.app.color());
let mut c = Colorizer::new(false, self.app.get_color());
c.none(msg);
ClapError::new(c, ErrorKind::DisplayVersion)
}
Expand Down

0 comments on commit 937d76a

Please sign in to comment.