Class: Boson::BareRunner
- Inherits:
-
Object
- Object
- Boson::BareRunner
- Extended by:
- API
- Defined in:
- lib/boson/bare_runner.rb
Overview
Base class for runners.
Defined Under Namespace
Modules: API
Constant Summary collapse
- DEFAULT_LIBRARIES =
[]
- GLOBAL_OPTIONS =
Default options for parse_args
{ help: { type: :boolean, desc: "Displays this help message" } }
Class Method Summary collapse
-
.allowed_argument_error?(err, cmd, args) ⇒ Boolean
Determines if a user command argument error or an internal Boson one.
-
.execute_command(cmd, args) ⇒ Object
Executes a command and handles invalid args.
-
.no_command_error(cmd) ⇒ Object
Use to abort when no command found.
Methods included from API
abort_with, all_libraries, default_libraries, init, start
Class Method Details
.allowed_argument_error?(err, cmd, args) ⇒ Boolean
Determines if a user command argument error or an internal Boson one
57 58 59 60 |
# File 'lib/boson/bare_runner.rb', line 57 def allowed_argument_error?(err, cmd, args) (err.[/wrong number of arguments/] && (cmd_obj = Command.find(cmd)) && cmd_obj.arg_size != args.size) end |
.execute_command(cmd, args) ⇒ Object
Executes a command and handles invalid args
41 42 43 44 45 46 47 48 49 |
# File 'lib/boson/bare_runner.rb', line 41 def execute_command(cmd, args) Boson.full_invoke(cmd, args) rescue ArgumentError raise if !allowed_argument_error?($!, cmd, args) abort_with "'#{cmd}' was called incorrectly.\nUsage: " + Command.usage(cmd) rescue NoMethodError => err raise if !err.backtrace.first.include?('`full_invoke') no_command_error cmd end |
.no_command_error(cmd) ⇒ Object
Use to abort when no command found
52 53 54 |
# File 'lib/boson/bare_runner.rb', line 52 def no_command_error(cmd) abort_with %[Could not find command "#{cmd}"] end |