Skip to content

Commit

Permalink
Group overrides from the same language together
Browse files Browse the repository at this point in the history
No functional change, but makes --list-languages easier to read.

Fixes #549
  • Loading branch information
Wilfred committed Aug 25, 2023
1 parent 21cdbe1 commit ca44de7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::{env, ffi::OsStr, path::Path, path::PathBuf};
use clap::{crate_authors, crate_description, Arg, Command};
use const_format::formatcp;
use crossterm::tty::IsTty;
use itertools::Itertools;

use crate::{
display::style::BackgroundColor,
Expand Down Expand Up @@ -467,7 +468,18 @@ fn parse_overrides_or_die(raw_overrides: &[String]) -> Vec<(LanguageOverride, Ve
std::process::exit(EXIT_BAD_ARGUMENTS);
}

res
res.into_iter()
.coalesce(
|(prev_lang, mut prev_globs), (current_lang, current_globs)| {
if prev_lang == current_lang {
prev_globs.extend(current_globs);
Ok((prev_lang, prev_globs))
} else {
Err(((prev_lang, prev_globs), (current_lang, current_globs)))
}
},
)
.collect()
}

/// Parse CLI arguments passed to the binary.
Expand Down
2 changes: 1 addition & 1 deletion src/parse/guess_language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub enum Language {
Zig,
}

#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum LanguageOverride {
Language(Language),
PlainText,
Expand Down

0 comments on commit ca44de7

Please sign in to comment.