Skip to content

Commit

Permalink
recommended
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbastian committed Jun 27, 2023
1 parent 32d7aa5 commit 210b5ef
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
11 changes: 7 additions & 4 deletions provider/datagen/src/bin/datagen/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ impl CollationTable {
#[command(about = format!("Learn more at: https://docs.rs/icu_datagen/{}", option_env!("CARGO_PKG_VERSION").unwrap_or("")), long_about = None)]
#[command(group(
ArgGroup::new("key_mode")
// .required(true)
.args(["keys", "key_file", "keys_for_bin", "all_keys"]),
.required(true)
.args(["keys", "key_file", "keys_for_bin", "all_keys", "config"]),
))]
pub struct Cli {
#[arg(short, long)]
Expand Down Expand Up @@ -202,10 +202,11 @@ pub struct Cli {
#[arg(help = "Deprecated: alias for --keys all")]
all_keys: bool,

#[arg(long, short, num_args = 0..)]
#[arg(long, short, num_args = 0.., default_value = "recommended")]
#[arg(
help = "Include this locale in the output. Accepts multiple arguments. \
Set to 'full' or 'modern' for the respective CLDR locale sets, or 'none' for no locales."
Set to 'full' or 'modern' for the respective CLDR locale sets, 'none' for no locales, \
or 'recommended' for the recommended set of locales."
)]
locales: Vec<String>,

Expand Down Expand Up @@ -325,6 +326,8 @@ impl Cli {
fn make_locales(&self) -> eyre::Result<config::LocaleInclude> {
Ok(if self.locales.as_slice() == ["none"] {
config::LocaleInclude::None
} else if self.locales.as_slice() == ["recommended"] {
config::LocaleInclude::Recommended
} else if self.locales.as_slice() == ["full"] || self.all_locales {
config::LocaleInclude::All
} else if let Some(locale_subsets) = self
Expand Down
10 changes: 10 additions & 0 deletions provider/datagen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,16 @@ impl DatagenProvider {
),
options::LocaleInclude::Explicit(set) => options::LocaleInclude::Explicit(set),
options::LocaleInclude::All => options::LocaleInclude::All,
options::LocaleInclude::Recommended => options::LocaleInclude::Explicit(
source
.locales(&[
CoverageLevel::Modern,
CoverageLevel::Moderate,
CoverageLevel::Basic,
])?
.into_iter()
.collect(),
),
};

if source.options.fallback == options::FallbackMode::Runtime {
Expand Down
5 changes: 5 additions & 0 deletions provider/datagen/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ pub enum LocaleInclude {
Explicit(HashSet<LanguageIdentifier>),
/// All locales with the given CLDR coverage levels
CldrSet(HashSet<CoverageLevel>),
/// A recommended set of locales.
///
/// This currently resolves to `CldrSet({Modern, Moderate, Basic}) but
/// might change in future releases.
Recommended,
}

impl Default for LocaleInclude {
Expand Down

0 comments on commit 210b5ef

Please sign in to comment.