Class: Miguel::Command
- Inherits:
-
Object
- Object
- Miguel::Command
- Defined in:
- lib/miguel/command.rb
Overview
Miguel command line interface.
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#force ⇒ Object
readonly
Returns the value of attribute force.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#loggers ⇒ Object
readonly
Returns the value of attribute loggers.
-
#quiet ⇒ Object
readonly
Returns the value of attribute quiet.
-
#trace ⇒ Object
readonly
Returns the value of attribute trace.
Instance Method Summary collapse
-
#init ⇒ Object
Initialize the command options.
-
#run(args) ⇒ Object
Run the command.
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
11 12 13 |
# File 'lib/miguel/command.rb', line 11 def env @env end |
#force ⇒ Object (readonly)
Returns the value of attribute force.
11 12 13 |
# File 'lib/miguel/command.rb', line 11 def force @force end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
11 12 13 |
# File 'lib/miguel/command.rb', line 11 def format @format end |
#loggers ⇒ Object (readonly)
Returns the value of attribute loggers.
11 12 13 |
# File 'lib/miguel/command.rb', line 11 def loggers @loggers end |
#quiet ⇒ Object (readonly)
Returns the value of attribute quiet.
11 12 13 |
# File 'lib/miguel/command.rb', line 11 def quiet @quiet end |
#trace ⇒ Object (readonly)
Returns the value of attribute trace.
11 12 13 |
# File 'lib/miguel/command.rb', line 11 def trace @trace end |
Instance Method Details
#init ⇒ Object
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. exit 1 end |