fix(cli): Don't crash on --locale

This commit is contained in:
Ed Page 2022-11-03 22:08:04 -05:00
parent e87d192bc5
commit f71f83b439

View file

@ -1,3 +1,4 @@
use clap::builder::TypedValueParser;
use clap::Parser; use clap::Parser;
use typos_cli::config; use typos_cli::config;
@ -129,7 +130,11 @@ pub(crate) struct FileArgs {
/// Only allow ASCII characters in identifiers /// Only allow ASCII characters in identifiers
no_unicode: bool, no_unicode: bool,
#[arg(long, value_parser = clap::builder::PossibleValuesParser::new(config::Locale::variants()))] #[arg(long)]
#[arg(
value_parser = clap::builder::PossibleValuesParser::new(config::Locale::variants())
.map(|l| l.parse::<config::Locale>().unwrap())
)]
pub(crate) locale: Option<config::Locale>, pub(crate) locale: Option<config::Locale>,
} }