Class: Ronin::UI::CLI::ScriptCommand
- Inherits:
-
ModelCommand
- Object
- Thor::Group
- Command
- ModelCommand
- Ronin::UI::CLI::ScriptCommand
- Defined in:
- lib/ronin/ui/cli/script_command.rb
Overview
A base-command for querying and loading Scripts.
Class Method Summary collapse
-
.script_class(script) ⇒ Script
protected
Defines the class to load scripts from.
Instance Method Summary collapse
-
#execute ⇒ Object
Loads the script, sets its parameters and runs the script.
-
#load_script ⇒ Script?
protected
Loads an script using the commands options.
Methods inherited from ModelCommand
each_query_option, model, #query, query_option, query_options, #setup
Methods inherited from Command
banner, command_name, #indent, inherited, #initialize, #print_array, #print_exception, #print_hash, #print_section, #print_title, #puts, run, #setup
Constructor Details
This class inherits a constructor from Ronin::UI::CLI::Command
Class Method Details
.script_class(script) ⇒ Script (protected)
Defines the class to load scripts from.
82 83 84 85 86 87 88 |
# File 'lib/ronin/ui/cli/script_command.rb', line 82 def self.script_class(script) unless script.included_modules.include?(Script) raise(ArgumentError,"#{script} does not include Ronin::Script") end model(script) end |
Instance Method Details
#execute ⇒ Object
Loads the script, sets its parameters and runs the script.
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/ronin/ui/cli/script_command.rb', line 51 def execute script = load_script script.params = [:params] if .console? print_info "Starting the console with @script set ..." UI::Console.start(:script => script) else script.run end end |
#load_script ⇒ Script? (protected)
Loads an script using the commands options.
104 105 106 107 108 109 110 |
# File 'lib/ronin/ui/cli/script_command.rb', line 104 def load_script if [:file] self.class.model.load_from([:file]) else query.load_first end end |