Class: Crowdin2csv::CLI
- Inherits:
-
Object
- Object
- Crowdin2csv::CLI
- Defined in:
- lib/crowdin2csv/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
- #execute(args) ⇒ Object
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
11 12 13 |
# File 'lib/crowdin2csv/cli.rb', line 11 def initialize @output_filename = nil end |
Class Method Details
.execute(args) ⇒ Object
7 8 9 |
# File 'lib/crowdin2csv/cli.rb', line 7 def self.execute(args) new.execute(args) end |
Instance Method Details
#execute(args) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/crowdin2csv/cli.rb', line 15 def execute(args) opts = option_parser opts.parse!(args) raise Crowdin2csv::Error, 'xliff file not found.' if args.size != 1 filename = args[0] raise Crowdin2csv::Error, 'xliff file is invalid.' unless File.file?(filename) output_filename = @output_filename || "#{File.basename(filename, '.xliff')}.csv" Crowdin2csv.crowdin2csv(filename, output_filename) rescue Crowdin2csv::Error => e warn e., opts.help exit 1 end |