Skip to content

Commit

Permalink
Merge pull request #267 from ruby-i18n/movermeyer/thor_list_fix
Browse files Browse the repository at this point in the history
Fix list parameter parsing
  • Loading branch information
movermeyer authored Nov 30, 2024
2 parents ddc56ec + 7be6b5e commit e97c662
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
14 changes: 4 additions & 10 deletions lib/cldr/thor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def download

desc "export [--locales=de fr-FR en-ZA] [--components=Numbers Plurals] [--target=#{Cldr::Export::DEFAULT_TARGET}] [--merge/--no-merge]",
"Export CLDR data by locales and components to target dir"
option :locales, aliases: [:l], type: :array, banner: "de fr-FR en-ZA", enum: Cldr::Export::Data::RAW_DATA.locales
option :components, aliases: [:c], type: :array, banner: "Numbers Plurals", enum: Cldr::Export::Data.components
option :locales, aliases: [:l], type: :array, banner: "de fr-FR en-ZA", enum: Cldr::Export::Data::RAW_DATA.locales.map(&:to_s)
option :components, aliases: [:c], type: :array, banner: "Numbers Plurals", enum: Cldr::Export::Data.components.map(&:to_s)
option :target, aliases: [:t], type: :string, default: Cldr::Export::DEFAULT_TARGET, banner: Cldr::Export::DEFAULT_TARGET
option :draft_status,
aliases: [:d],
Expand All @@ -53,17 +53,11 @@ def export

formatted_options = options.dup.symbolize_keys

# We do this validation, since thor doesn't
# https://github.com/rails/thor/issues/783
if formatted_options.key?(:locales)
formatted_options[:locales] = formatted_options[:locales].map(&:to_sym) if formatted_options.key?(:locales)
unknown_locales = formatted_options[:locales] - Cldr::Export::Data::RAW_DATA.locales
raise ArgumentError, "Unknown locales: #{unknown_locales.map { |l| "`#{l}`" }.join(", ")}" unless unknown_locales.empty?
formatted_options[:locales] = formatted_options[:locales].map(&:to_sym)
end
if formatted_options.key?(:components)
formatted_options[:components] = formatted_options[:components].map(&:to_sym) if formatted_options.key?(:components)
unknown_components = formatted_options[:components] - Cldr::Export::Data.components
raise ArgumentError, "Unknown components: #{unknown_components.join(", ")}" unless unknown_components.empty?
formatted_options[:components] = formatted_options[:components].map(&:to_sym)
end

if formatted_options.key?(:draft_status)
Expand Down
4 changes: 2 additions & 2 deletions ruby-cldr.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency("nokogiri", [">= 0"])
s.add_runtime_dependency("psych", [">= 4.0.0"])
s.add_runtime_dependency("rubyzip", [">= 0"])
s.add_runtime_dependency("thor", [">= 0"])
s.add_runtime_dependency("thor", [">= 1.3.0"])
s.add_development_dependency("jeweler", [">= 0"])
s.add_development_dependency("pry", [">= 0"])
s.add_development_dependency("pry-nav", [">= 0"])
Expand All @@ -165,6 +165,6 @@ Gem::Specification.new do |s|
s.add_dependency("ruby-lsp", [">= 0"])
s.add_dependency("rubyzip", [">= 0"])
s.add_dependency("test-unit", [">= 0"])
s.add_dependency("thor", [">= 0"])
s.add_dependency("thor", [">= 1.3.0"])
end
end

0 comments on commit e97c662

Please sign in to comment.