Class: Miguel::Command

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

Overview

Miguel command line interface.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



11
12
13
# File 'lib/miguel/command.rb', line 11

def env
  @env
end

#forceObject (readonly)

Returns the value of attribute force.



11
12
13
# File 'lib/miguel/command.rb', line 11

def force
  @force
end

#formatObject (readonly)

Returns the value of attribute format.



11
12
13
# File 'lib/miguel/command.rb', line 11

def format
  @format
end

#loggersObject (readonly)

Returns the value of attribute loggers.



11
12
13
# File 'lib/miguel/command.rb', line 11

def loggers
  @loggers
end

#quietObject (readonly)

Returns the value of attribute quiet.



11
12
13
# File 'lib/miguel/command.rb', line 11

def quiet
  @quiet
end

#traceObject (readonly)

Returns the value of attribute trace.



11
12
13
# File 'lib/miguel/command.rb', line 11

def trace
  @trace
end

Instance Method Details

#initObject

Initialize the command options.



14
15
16
17
18
19
20
21
# File 'lib/miguel/command.rb', line 14

def init
  @env = nil
  @format = nil
  @loggers = []
  @force = nil
  @quiet = nil
  @trace = nil
end

#run(args) ⇒ Object

Run the command.



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/miguel/command.rb', line 24

def run( args )
  args = args.dup
  init
  OptionParser.new( &method( :set_opts ) ).parse!( args )
  execute( args )
  exit 0
rescue Exception => e
  raise if trace or e.is_a?( SystemExit )
  $stderr.print "#{e.class}: " unless e.is_a?( RuntimeError )
  $stderr.puts e.message
  exit 1
end