Class: Mirah::Commands::Base
- Inherits:
-
Object
- Object
- Mirah::Commands::Base
- Includes:
- Logging::Logged
- Defined in:
- lib/mirah/commands/base.rb
Constant Summary
Constants included from Logging::Logged
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#argument_processor ⇒ Object
Returns the value of attribute argument_processor.
-
#state ⇒ Object
Returns the value of attribute state.
Instance Method Summary collapse
- #execute_base ⇒ Object
-
#initialize(args) ⇒ Base
constructor
A new instance of Base.
Methods included from Logging::Logged
#error, #info, #log, #logger, #logger_name, #logging?, #vlog, #warning
Constructor Details
#initialize(args) ⇒ Base
Returns a new instance of Base.
24 25 26 27 28 29 |
# File 'lib/mirah/commands/base.rb', line 24 def initialize(args) @state = Mirah::Util::CompilationState.new @state.command = command_name @args = args @argument_processor = Mirah::Util::ArgumentProcessor.new(@state, @args) end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
31 32 33 |
# File 'lib/mirah/commands/base.rb', line 31 def args @args end |
#argument_processor ⇒ Object
Returns the value of attribute argument_processor.
31 32 33 |
# File 'lib/mirah/commands/base.rb', line 31 def argument_processor @argument_processor end |
#state ⇒ Object
Returns the value of attribute state.
31 32 33 |
# File 'lib/mirah/commands/base.rb', line 31 def state @state end |
Instance Method Details
#execute_base ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/mirah/commands/base.rb', line 33 def execute_base argument_processor.process if argument_processor.exit? exit argument_processor.exit_status_code end # because MirahCommand is a JRuby Java class, SystemExit bubbles through and makes noise # so we use a catch/throw to early exit instead # see util/process_errors.rb status = catch(:exit) do begin yield rescue Mirah::InternalCompilerError => ice Mirah.print_error(ice., ice.position) if ice.node raise ice.cause || ice rescue Mirah::MirahError => ex Mirah.print_error(ex., ex.position) log "{0}\n{1}", [ex., ex.backtrace.join("\n")] throw :exit, 1 end 0 end exit status if status > 0 true end |