Skip to content

Commit 1d1b088

Browse files
committed
Add colors to --help
1 parent 8661ac4 commit 1d1b088

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Upcoming release
22

33
## Features
4-
4+
- Add colors to `--help`, see #1846 (@starsep)
55

66
## Bugfixes
77

src/cli.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ use std::path::{Path, PathBuf};
33
use std::time::Duration;
44

55
use anyhow::anyhow;
6+
use clap::builder::Styles;
7+
use clap::builder::styling::{AnsiColor, Effects};
68
use clap::{
79
Arg, ArgAction, ArgGroup, ArgMatches, Command, Parser, ValueEnum, error::ErrorKind,
810
value_parser,
@@ -18,6 +20,12 @@ use crate::filesystem;
1820
use crate::filter::OwnerFilter;
1921
use crate::filter::SizeFilter;
2022

23+
const STYLES: Styles = Styles::styled()
24+
.header(AnsiColor::Green.on_default().effects(Effects::BOLD))
25+
.usage(AnsiColor::Green.on_default().effects(Effects::BOLD))
26+
.literal(AnsiColor::Cyan.on_default().effects(Effects::BOLD))
27+
.placeholder(AnsiColor::Cyan.on_default());
28+
2129
#[derive(Parser)]
2230
#[command(
2331
name = "fd",
@@ -28,6 +36,7 @@ use crate::filter::SizeFilter;
2836
args_override_self = true,
2937
group(ArgGroup::new("execs").args(&["exec", "exec_batch", "list_details"]).conflicts_with_all(&[
3038
"max_results", "quiet", "max_one_result"])),
39+
styles = STYLES,
3140
)]
3241
pub struct Opts {
3342
/// Include hidden directories and files in the search results (default:

0 commit comments

Comments
 (0)