Class: PutText::Cmdline

Inherits:
Object
  • Object
show all
Defined in:
lib/puttext/cmdline.rb

Constant Summary collapse

USAGE_TEXT =
'Usage: puttext LOCATION [options]'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.run(args) ⇒ Object

Run the commmand line tool puttext.

Parameters:

  • args (Array<String>)

    the command line arguments.



12
13
14
# File 'lib/puttext/cmdline.rb', line 12

def self.run(args)
  new.run(args)
end

Instance Method Details

#run(args) ⇒ Object

Run the commmand line tool puttext.

Parameters:

  • args (Array<String>)

    the command line arguments.



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/puttext/cmdline.rb', line 18

def run(args)
  options = parse_args(args)
  po_file = Extractor.new.extract(options[:path])

  if options[:output_file]
    with_output_file(options[:output_file]) { |f| po_file.write_to(f) }
  else
    po_file.write_to(STDOUT)
  end
rescue => e
  error(e)
end