From b00c498b1f3d889b15465ed6336f4dc6a7f784e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Fri, 27 Sep 2024 14:35:44 +0200 Subject: [PATCH] Add --print-unicode-blocks and --verbose Allows the user to discover all supported unicode blocks --- src/main.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/main.rs b/src/main.rs index 5d98787..89bf231 100644 --- a/src/main.rs +++ b/src/main.rs @@ -111,6 +111,15 @@ impl RuleDispatcher { struct Args { /// One or more files or directories to scan. Directories are scanned recursively. paths: Vec, + + /// Print the names of all the Unicode blocks that this tool recognizes, then exits. + /// Enable verbose output to also print the code point ranges for each block. + #[arg(long)] + print_unicode_blocks: bool, + + /// Enable more verbose output. + #[arg(short, long)] + verbose: bool, } fn main() -> anyhow::Result<()> { @@ -118,6 +127,19 @@ fn main() -> anyhow::Result<()> { let args = Args::parse(); + if args.print_unicode_blocks { + for (&name, range) in &unicode_blocks::UNICODE_BLOCKS { + print!("{name}"); + if args.verbose { + let range_start = u32::from(*range.start()); + let range_end = u32::from(*range.end()); + print!(": U+{range_start}..U+{range_end}"); + } + println!(); + } + return Ok(()); + } + let default_config = get_default_config(); let mut dispatcher = RuleDispatcher { user_config: None,