Class: HTML2Slim::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/html2slim/command.rb

Direct Known Subclasses

ERBCommand, HTMLCommand

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Command

Returns a new instance of Command.



7
8
9
10
# File 'lib/html2slim/command.rb', line 7

def initialize(args)
  @args    = args
  @options = {}
end

Instance Method Details

#runObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/html2slim/command.rb', line 12

def run
  @opts = OptionParser.new(&method(:set_opts))
  @opts.parse!(@args)
  process!
  exit 0
rescue Exception => ex
  raise ex if @options[:trace] || SystemExit === ex
  $stderr.print "#{ex.class}: " if ex.class != RuntimeError
  $stderr.puts ex.message
  $stderr.puts '  Use --trace for backtrace.'
  exit 1
end