diff --git a/src/main.rs b/src/main.rs index a49f32d8..7a7129ca 100644 --- a/src/main.rs +++ b/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 { + 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 { + 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 { + 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 { - 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 { - 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 { - 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();