From 92a1172bfab28bb687c7a3b526af0d1fe94f0273 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 30 Apr 2021 10:32:15 -0500 Subject: [PATCH] feat(ddi): Allow controlling 'unicode' via args --- docs/reference.md | 2 +- src/args.rs | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/reference.md b/docs/reference.md index cfede19..a9fed8f 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -23,7 +23,7 @@ Configuration is read from the following (in precedence order) | default.binary | --binary | bool | Check binary files as text | | default.check-filename | \- | bool | Verifying spelling in file names. | | default.check-file | \- | bool | Verifying spelling in files. | -| default.unicode | \- | bool | Allow unicode characters in identifiers (and not just ASCII) | +| default.unicode | --unicode | bool | Allow unicode characters in identifiers (and not just ASCII) | | default.ignore-hex | \- | bool | Do not check identifiers that appear to be hexadecimal values. | | default.identifier-leading-digits | \- | bool | Allow identifiers to start with digits, in addition to letters. | | default.locale | --locale | en, en-us, en-gb, en-ca, en-au | English dialect to correct to. | diff --git a/src/args.rs b/src/args.rs index 44e25f2..53f96ac 100644 --- a/src/args.rs +++ b/src/args.rs @@ -123,6 +123,12 @@ pub(crate) struct FileArgs { #[structopt(long, overrides_with("no-check-files"), hidden(true))] check_files: bool, + #[structopt(long, overrides_with("no-unicode"), hidden(true))] + unicode: bool, + #[structopt(long, overrides_with("unicode"))] + /// Only allow ASCII characters in identifiers + no_unicode: bool, + #[structopt( long, possible_values(&config::Locale::variants()), @@ -136,7 +142,10 @@ impl FileArgs { binary: self.binary(), check_filename: self.check_filename(), check_file: self.check_file(), - tokenizer: None, + tokenizer: Some(config::TokenizerConfig { + unicode: self.unicode(), + ..Default::default() + }), dict: Some(config::DictConfig { locale: self.locale, ..Default::default() @@ -152,6 +161,10 @@ impl FileArgs { resolve_bool_arg(self.check_filenames, self.no_check_filenames) } + fn unicode(&self) -> Option { + resolve_bool_arg(self.unicode, self.no_unicode) + } + fn check_file(&self) -> Option { resolve_bool_arg(self.check_files, self.no_check_files) }