Skip to content

Instantly share code, notes, and snippets.

@etdsoft
Created April 2, 2011 11:08
Show Gist options
  • Save etdsoft/899404 to your computer and use it in GitHub Desktop.
Save etdsoft/899404 to your computer and use it in GitHub Desktop.
Dradis Console
#!/usr/bin/env ruby
require 'rubygems'
require 'optparse'
require 'irb'
require 'irb/completion'
require 'rails'
module Dradis
class Console
def self.start(app)
new(app).start
end
def initialize(app)
@app = app
end
def start
options = {}
OptionParser.new do |opt|
opt.banner = "Usage: dradis [environment] [options]"
opt.parse!(ARGV)
end
@app.load_console(options[:sandbox])
IRB.setup(nil)
IRB.conf[:PROMPT][:DRADIS_PROMPT] = {
:PROMPT_I => "dradis>> ", # default
:PROMPT_S => nil, # continuing strings
:PROMPT_C => "?> ", # continuing commands
:RETURN => "=> %s\n"
}
IRB.conf[:PROMPT_MODE] = :DRADIS_PROMPT
irb = IRB::Irb.new
IRB.conf[:IRB_RC].call(irb.context) if IRB.conf[:IRB_RC]
IRB.conf[:MAIN_CONTEXT] = irb.context
trap("SIGINT") do
irb.signal_handle
end
catch(:IRB_EXIT) do
irb.eval_input
end
end
end
end
if __FILE__ == $0
APP_PATH = File.expand_path('../server/config/application', __FILE__)
require APP_PATH
Rails.application.require_environment!
Dradis::Console.start(Rails.application)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment