Class: Ego::Runner
- Inherits:
-
Object
- Object
- Ego::Runner
- Defined in:
- lib/ego/runner.rb
Overview
The Runner class, given an array of arguments, initializes the required objects and executes the request.
Constant Summary collapse
- PROMPT =
Prompt to display in shell-mode
'ego, '.green.freeze
- QUIT =
Pattern that triggers shell-mode to exit
/^q(uit)?|exit|(good)?bye$/
Instance Method Summary collapse
-
#initialize(argv) ⇒ Runner
constructor
Takes an array of arguments and parses them into options:.
-
#run ⇒ void
Run the appropriate action based on the arguments provided to
#initialize.
Constructor Details
#initialize(argv) ⇒ Runner
Takes an array of arguments and parses them into options:
22 23 24 |
# File 'lib/ego/runner.rb', line 22 def initialize(argv) = Options.new(argv) end |
Instance Method Details
#run ⇒ void
This method returns an undefined value.
Run the appropriate action based on the arguments provided to
#initialize.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ego/runner.rb', line 30 def run case .mode when :help Printer.errs .usage_error, "\n" if .usage_error Printer.puts .usage exit(-1) if .usage_error when :version Printer.puts "ego v#{Ego::VERSION}" when :template helper = PluginHelper.new( query: (.query unless .query.empty?), program_name: .usage.program_name ) Printer.puts helper.template when :shell start_shell(robot_factory) else handle_query(robot_factory, .query) end rescue RobotError => e Printer.errs e. exit(-2) end |