mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-25 02:20:58 -05:00
refactor(cli): Re-order code to make diffing easier
This commit is contained in:
parent
26787df50d
commit
8ea31b5e1d
1 changed files with 59 additions and 59 deletions
118
src/main.rs
118
src/main.rs
|
@ -73,6 +73,65 @@ impl Args {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(rename_all = "kebab-case")]
|
||||
pub struct FileArgs {
|
||||
#[structopt(long, raw(overrides_with = r#""check-filenames""#))]
|
||||
/// Skip verifying spelling in file names.
|
||||
no_check_filenames: bool,
|
||||
#[structopt(
|
||||
long,
|
||||
raw(overrides_with = r#""no-check-filenames""#),
|
||||
raw(hidden = "true")
|
||||
)]
|
||||
check_filenames: bool,
|
||||
|
||||
#[structopt(long, raw(overrides_with = r#""check-files""#))]
|
||||
/// Skip verifying spelling in filess.
|
||||
no_check_files: bool,
|
||||
#[structopt(
|
||||
long,
|
||||
raw(overrides_with = r#""no-check-files""#),
|
||||
raw(hidden = "true")
|
||||
)]
|
||||
check_files: bool,
|
||||
|
||||
#[structopt(long, raw(overrides_with = r#""hex""#))]
|
||||
/// Don't try to detect that an identifier looks like hex
|
||||
no_hex: bool,
|
||||
#[structopt(long, raw(overrides_with = r#""no-hex""#), raw(hidden = "true"))]
|
||||
hex: bool,
|
||||
}
|
||||
|
||||
impl config::FileSource for FileArgs {
|
||||
fn check_filename(&self) -> Option<bool> {
|
||||
match (self.check_filenames, self.no_check_filenames) {
|
||||
(true, false) => Some(true),
|
||||
(false, true) => Some(false),
|
||||
(false, false) => None,
|
||||
(_, _) => unreachable!("StructOpt should make this impossible"),
|
||||
}
|
||||
}
|
||||
|
||||
fn check_file(&self) -> Option<bool> {
|
||||
match (self.check_files, self.no_check_files) {
|
||||
(true, false) => Some(true),
|
||||
(false, true) => Some(false),
|
||||
(false, false) => None,
|
||||
(_, _) => unreachable!("StructOpt should make this impossible"),
|
||||
}
|
||||
}
|
||||
|
||||
fn ignore_hex(&self) -> Option<bool> {
|
||||
match (self.hex, self.no_hex) {
|
||||
(true, false) => Some(true),
|
||||
(false, true) => Some(false),
|
||||
(false, false) => None,
|
||||
(_, _) => unreachable!("StructOpt should make this impossible"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(rename_all = "kebab-case")]
|
||||
struct ConfigArgs {
|
||||
|
@ -205,65 +264,6 @@ impl config::WalkSource for WalkArgs {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(rename_all = "kebab-case")]
|
||||
pub struct FileArgs {
|
||||
#[structopt(long, raw(overrides_with = r#""check-filenames""#))]
|
||||
/// Skip verifying spelling in file names.
|
||||
no_check_filenames: bool,
|
||||
#[structopt(
|
||||
long,
|
||||
raw(overrides_with = r#""no-check-filenames""#),
|
||||
raw(hidden = "true")
|
||||
)]
|
||||
check_filenames: bool,
|
||||
|
||||
#[structopt(long, raw(overrides_with = r#""check-files""#))]
|
||||
/// Skip verifying spelling in filess.
|
||||
no_check_files: bool,
|
||||
#[structopt(
|
||||
long,
|
||||
raw(overrides_with = r#""no-check-files""#),
|
||||
raw(hidden = "true")
|
||||
)]
|
||||
check_files: bool,
|
||||
|
||||
#[structopt(long, raw(overrides_with = r#""hex""#))]
|
||||
/// Don't try to detect that an identifier looks like hex
|
||||
no_hex: bool,
|
||||
#[structopt(long, raw(overrides_with = r#""no-hex""#), raw(hidden = "true"))]
|
||||
hex: bool,
|
||||
}
|
||||
|
||||
impl config::FileSource for FileArgs {
|
||||
fn check_filename(&self) -> Option<bool> {
|
||||
match (self.check_filenames, self.no_check_filenames) {
|
||||
(true, false) => Some(true),
|
||||
(false, true) => Some(false),
|
||||
(false, false) => None,
|
||||
(_, _) => unreachable!("StructOpt should make this impossible"),
|
||||
}
|
||||
}
|
||||
|
||||
fn check_file(&self) -> Option<bool> {
|
||||
match (self.check_files, self.no_check_files) {
|
||||
(true, false) => Some(true),
|
||||
(false, true) => Some(false),
|
||||
(false, false) => None,
|
||||
(_, _) => unreachable!("StructOpt should make this impossible"),
|
||||
}
|
||||
}
|
||||
|
||||
fn ignore_hex(&self) -> Option<bool> {
|
||||
match (self.hex, self.no_hex) {
|
||||
(true, false) => Some(true),
|
||||
(false, true) => Some(false),
|
||||
(false, false) => None,
|
||||
(_, _) => unreachable!("StructOpt should make this impossible"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_logging(level: log::Level) -> env_logger::Builder {
|
||||
let mut builder = env_logger::Builder::new();
|
||||
|
||||
|
|
Loading…
Reference in a new issue