Class: I18nize::CLI
- Inherits:
-
Object
- Object
- I18nize::CLI
- Defined in:
- lib/i18nize/cli.rb
Overview
CLI for i18nize
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
Constructor Details
#initialize(argv) ⇒ CLI
Returns a new instance of CLI.
15 16 17 18 19 20 21 22 |
# File 'lib/i18nize/cli.rb', line 15 def initialize(argv) @argv = argv.dup @options = { from: "en", mode: :translate, # :translate | :missing | :only_blank missing_from: nil } end |
Class Method Details
.run(argv) ⇒ Object
11 12 13 |
# File 'lib/i18nize/cli.rb', line 11 def self.run(argv) new(argv).run end |
Instance Method Details
#run ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/i18nize/cli.rb', line 24 def run remaining = parse_flags!(@argv) abort usage unless remaining.any? to_locale = remaining.shift.strip case @options[:mode] when :missing from = @options[:missing_from] || @options[:from] show_missing_translations(from:, to: to_locale) when :only_blank run_only_blank(to_locale) else run_translation(to_locale) end 0 rescue OptionParser::InvalidOption => e warn red(e.) puts usage 2 rescue SystemExit => e raise e rescue => e warn red("Error: #{e.class}: #{e.}") e.backtrace.each { |l| warn l } if ENV["I18NIZE_DEBUG"] == "1" 1 end |