Skip to content

Commit

Permalink
[WIP] rename --no-color to --no-ansi
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieMason committed Oct 28, 2024
1 parent adfd486 commit f9bec24
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ fn log_levels_option(command: &str) -> Arg {
}

fn no_color_option(command: &str) -> Arg {
Arg::new("no-color")
.long("no-color")
Arg::new("no-ansi")
.long("no-ansi")
.long_help(cformat!(
r#"Disable colored output
r#"Disable ANSI colored output and terminal hyperlinks
<bold><underline>Examples</underline></bold>
<dim>$</dim> <yellow><bold>syncpack {command}</bold> --no-color</>"#
<dim>$</dim> <yellow><bold>syncpack {command}</bold> --no-ansi</>"#
))
.action(clap::ArgAction::SetTrue)
}
Expand Down Expand Up @@ -202,7 +202,7 @@ fn validate_source(value: &str) -> Result<String, String> {
#[derive(Debug)]
pub struct CliOptions {
pub dependency_name_regex: Option<Regex>,
pub disable_color: bool,
pub disable_ansi: bool,
pub inspect_formatting: bool,
pub inspect_mismatches: bool,
pub log_levels: Vec<LevelFilter>,
Expand All @@ -229,7 +229,7 @@ impl CliOptions {
let only = matches.get_many::<String>("only").unwrap().collect_vec();
CliOptions {
dependency_name_regex: matches.get_one::<String>("filter").map(|filter| Regex::new(filter).unwrap()),
disable_color: matches.get_flag("no-color"),
disable_ansi: matches.get_flag("no-ansi"),
inspect_formatting: only.contains(&&"formatting".to_string()),
inspect_mismatches: only.contains(&&"mismatches".to_string()),
log_levels: matches
Expand Down
2 changes: 1 addition & 1 deletion src/effects/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ impl<'a> Ui<'a> {

/// Render a clickable link
fn link(&self, url: impl Into<String>, text: impl Into<ColoredString>) -> ColoredString {
if self.ctx.config.cli.options.disable_color {
if self.ctx.config.cli.options.disable_ansi {
text.into().normal()
} else {
format!("\x1b]8;;{}\x1b\\{}\x1b]8;;\x1b\\", url.into(), text.into()).normal()
Expand Down
2 changes: 1 addition & 1 deletion src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use {

/// Initialize the logger with the given log level
pub fn init(cli_options: &CliOptions) {
if cli_options.disable_color {
if cli_options.disable_ansi {
colored::control::set_override(false);
}
if !cli_options.log_levels.contains(&LevelFilter::Off) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub fn cli() -> Cli {
command_name: Subcommand::Lint,
options: CliOptions {
dependency_name_regex: None,
disable_color: true,
disable_ansi: true,
inspect_formatting: false,
inspect_mismatches: true,
log_levels: vec![],
Expand Down

0 comments on commit f9bec24

Please sign in to comment.