Class: Ronin::UI::CLI::Commands::Exec
- Inherits:
-
Object
- Object
- Ronin::UI::CLI::Commands::Exec
- Includes:
- Output::Helpers
- Defined in:
- lib/ronin/ui/cli/commands/exec.rb
Overview
The ronin exec command.
Class Method Summary collapse
-
.start(argv = ARGV) ⇒ Object
Runs the
execcommand.
Instance Method Summary collapse
-
#execute ⇒ Object
Executes the
execcommand. -
#initialize(script, arguments = []) ⇒ Exec
constructor
Initializes the
execcommand. -
#setup_argv ⇒ Object
protected
Temporarily populates the
ARGVconstant.
Constructor Details
#initialize(script, arguments = []) ⇒ Exec
Initializes the exec command.
46 47 48 49 |
# File 'lib/ronin/ui/cli/commands/exec.rb', line 46 def initialize(script,arguments=[]) @script = script @arguments = arguments end |
Class Method Details
.start(argv = ARGV) ⇒ Object
Runs the exec command.
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/ronin/ui/cli/commands/exec.rb', line 57 def self.start(argv=ARGV) case argv[0] when '-h', '--help', nil puts "Usage:\n ronin-exec SCRIPT [ARGS...]\n\n" puts "Runs a script from a Ronin Repository" return false end self.new(argv[0],argv[1..-1]).execute end |
Instance Method Details
#execute ⇒ Object
Executes the exec command.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/ronin/ui/cli/commands/exec.rb', line 73 def execute if File.file?(@script) require 'ronin' setup_argv { load File.(@script) } return true end Database.setup Repository.each do |repo| path = repo.path.join(Repository::BIN_DIR,@script) if path.file? require 'ronin' repo.activate! setup_argv { load path } return true end end print_error "Could not find the script #{@script.dump}." return false end |
#setup_argv ⇒ Object (protected)
Temporarily populates the ARGV constant.
107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/ronin/ui/cli/commands/exec.rb', line 107 def setup_argv original_argv = ARGV.dup ARGV.clear @arguments.each { |arg| ARGV << arg } result = yield ARGV.clear original_argv.each { |arg| ARGV << arg } return result end |