Skip to content

Commit

Permalink
Add --draft-status CLI option
Browse files Browse the repository at this point in the history
  • Loading branch information
movermeyer committed Apr 20, 2022
1 parent 04b099c commit 690e496
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/cldr/thor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,18 @@ def download
Cldr::Download.download(options["source"], options["target"], options["version"])
end

DEFAULT_MINIMUM_DRAFT_STATUS = Cldr::DraftStatus::CONTRIBUTED

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.locales
option :components, aliases: [:c], type: :array, banner: "Numbers Plurals", enum: Cldr::Export::Data.components
option :target, aliases: [:t], type: :string, default: Cldr::Export::DEFAULT_TARGET, banner: Cldr::Export::DEFAULT_TARGET
option :draft_status, aliases: [:d], type: :string,
enum: Cldr::DraftStatus::ALL.map(&:to_s),
default: DEFAULT_MINIMUM_DRAFT_STATUS.to_s,
banner: DEFAULT_MINIMUM_DRAFT_STATUS.to_s,
desc: "The minimum draft status to include in the export"
option :merge, aliases: [:m], type: :boolean, default: false
def export
$stdout.sync
Expand All @@ -49,6 +56,11 @@ def export
raise ArgumentError, "Unknown components: #{unknown_components.join(", ")}" unless unknown_components.empty?
end

if formatted_options.key?(:draft_status)
formatted_options[:minimum_draft_status] = Cldr::DraftStatus.fetch(formatted_options[:draft_status])
formatted_options.delete(:draft_status)
end

Cldr::Export.export(formatted_options) { putc(".") }
puts
end
Expand Down

0 comments on commit 690e496

Please sign in to comment.