Class: Less2Sass::Exec::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/less2sass/exec/base.rb

Overview

The abstract base class for Less2Sass executables.

Direct Known Subclasses

Conversion

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Base

Returns a new instance of Base.

Parameters:

  • args (Array<String>)

    command-line arguments



8
9
10
11
# File 'lib/less2sass/exec/base.rb', line 8

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

Instance Method Details

#parseObject

Parses the command-line arguments and runs the executable.



29
30
31
32
33
34
35
36
37
38
# File 'lib/less2sass/exec/base.rb', line 29

def parse
  # @opts = OptionParser.new(&method(:set_opts))
  OptionParser.new do |opts|
    set_opts(opts)
  end.parse!(@args)

  process_args

  @options
end

#parse!Object

Parses the command-line arguments and runs the executable. Calls ‘Kernel#exit` at the end, so it never returns.

See Also:



17
18
19
20
21
22
23
24
25
26
# File 'lib/less2sass/exec/base.rb', line 17

def parse!
  begin
    parse
  rescue Exception => e
    raise e if @options[:trace] || e.is_a?(SystemExit)
    $stderr.puts "#{e.class}: " + e.message.to_s
    exit 1
  end
  exit 0
end