Skip to content

Commit

Permalink
Merge pull request #126 from iqlusioninc/usage/fix-legibility
Browse files Browse the repository at this point in the history
usage: Use bold rather than explicit color (fixes #105)
  • Loading branch information
tony-iqlusion authored Aug 6, 2019
2 parents a5e8904 + dd0bce9 commit ac481e1
Showing 1 changed file with 16 additions and 21 deletions.
37 changes: 16 additions & 21 deletions core/src/command/usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,10 @@ impl Usage {

command.print_info()?;

let mut white = ColorSpec::new();
white.set_fg(Some(Color::White));
white.set_bold(true);
let mut bold = ColorSpec::new();
bold.set_bold(true);

stdout.set_color(&white)?;
stdout.set_color(&bold)?;
writeln!(stdout, "USAGE:")?;
stdout.reset()?;

Expand All @@ -121,7 +120,7 @@ impl Usage {
writeln!(stdout)?;

if let Some(desc) = description {
stdout.set_color(&white)?;
stdout.set_color(&bold)?;
writeln!(stdout, "DESCRIPTION:")?;
stdout.reset()?;

Expand Down Expand Up @@ -180,11 +179,10 @@ impl Usage {
command.print_info().unwrap();

if let Some(desc) = description {
let mut white = ColorSpec::new();
white.set_fg(Some(Color::White));
white.set_bold(true);
let mut bold = ColorSpec::new();
bold.set_bold(true);

stdout.set_color(&white).unwrap();
stdout.set_color(&bold).unwrap();
writeln!(stdout, "DESCRIPTION:").unwrap();
stdout.reset().unwrap();

Expand Down Expand Up @@ -235,9 +233,8 @@ impl Usage {
writeln!(stdout, "wasn't recognized.")?;
writeln!(stdout)?;

let mut white = ColorSpec::new();
white.set_fg(Some(Color::White));
white.set_bold(true);
let mut bold = ColorSpec::new();
bold.set_bold(true);

stdout.set_color(&yellow)?;
writeln!(stdout, "USAGE:")?;
Expand All @@ -258,11 +255,10 @@ impl Usage {
let mut stdout = STDOUT.lock();
stdout.reset()?;

let mut white = ColorSpec::new();
white.set_fg(Some(Color::White));
white.set_bold(true);
let mut bold = ColorSpec::new();
bold.set_bold(true);

stdout.set_color(&white)?;
stdout.set_color(&bold)?;
writeln!(stdout, "{} {}", &self.package_name, &self.package_version)?;
stdout.reset()?;

Expand All @@ -282,12 +278,11 @@ impl Usage {
pub fn print_usage(&self) -> Result<(), io::Error> {
let mut stdout = STDOUT.lock();

let mut white = ColorSpec::new();
white.set_fg(Some(Color::White));
white.set_bold(true);
let mut bold = ColorSpec::new();
bold.set_bold(true);

if !self.args.is_empty() {
stdout.set_color(&white)?;
stdout.set_color(&bold)?;
writeln!(stdout, "FLAGS:")?;
stdout.reset()?;

Expand All @@ -299,7 +294,7 @@ impl Usage {
}

if !self.subcommands.is_empty() {
stdout.set_color(&white)?;
stdout.set_color(&bold)?;
writeln!(stdout, "SUBCOMMANDS:")?;
stdout.reset()?;

Expand Down

0 comments on commit ac481e1

Please sign in to comment.