add irb option for the cli script
This commit is contained in:
+37
-3
@@ -14,9 +14,7 @@ Options:
|
|||||||
HELP
|
HELP
|
||||||
|
|
||||||
require 'optparse'
|
require 'optparse'
|
||||||
|
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
require 'gollum/frontend/app'
|
|
||||||
|
|
||||||
exec = {}
|
exec = {}
|
||||||
options = {}
|
options = {}
|
||||||
@@ -31,6 +29,10 @@ opts = OptionParser.new do |opts|
|
|||||||
puts "Gollum " + Gollum::VERSION
|
puts "Gollum " + Gollum::VERSION
|
||||||
exit 0
|
exit 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
opts.on("--irb", "Start an irb process with gollum loaded for the current wiki.") do
|
||||||
|
options['irb'] = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Read command line options into `options` hash
|
# Read command line options into `options` hash
|
||||||
@@ -38,4 +40,36 @@ opts.parse!
|
|||||||
|
|
||||||
$path = ARGV[0] || Dir.pwd
|
$path = ARGV[0] || Dir.pwd
|
||||||
|
|
||||||
Precious::App.run!(options)
|
if options['irb']
|
||||||
|
require 'irb'
|
||||||
|
# http://jameskilton.com/2009/04/02/embedding-irb-into-your-ruby-application/
|
||||||
|
module IRB # :nodoc:
|
||||||
|
def self.start_session(binding)
|
||||||
|
unless @__initialized
|
||||||
|
args = ARGV
|
||||||
|
ARGV.replace(ARGV.dup)
|
||||||
|
IRB.setup(nil)
|
||||||
|
ARGV.replace(args)
|
||||||
|
@__initialized = true
|
||||||
|
end
|
||||||
|
|
||||||
|
workspace = WorkSpace.new(binding)
|
||||||
|
|
||||||
|
irb = Irb.new(workspace)
|
||||||
|
|
||||||
|
@CONF[:IRB_RC].call(irb.context) if @CONF[:IRB_RC]
|
||||||
|
@CONF[:MAIN_CONTEXT] = irb.context
|
||||||
|
|
||||||
|
catch(:IRB_EXIT) do
|
||||||
|
irb.eval_input
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
require 'gollum'
|
||||||
|
wiki = Gollum::Wiki.new $path
|
||||||
|
IRB.start_session binding
|
||||||
|
else
|
||||||
|
require 'gollum/frontend/app'
|
||||||
|
Precious::App.run!(options)
|
||||||
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user