bin/ronin-gen in ronin-gen-0.2.0 vs bin/ronin-gen in ronin-gen-1.0.0.pre1
- old
+ new
@@ -1,19 +1,38 @@
#!/usr/bin/env ruby
require 'rubygems'
-lib_dir = File.expand_path(File.join(File.dirname(__FILE__),'..','lib'))
-unless $LOAD_PATH.include?(lib_dir)
- $LOAD_PATH << lib_dir
+root_dir = File.expand_path(File.join(File.dirname(__FILE__),'..'))
+if File.directory?(File.join(root_dir,'.git'))
+ Dir.chdir(root_dir) do |path|
+ require 'bundler'
+
+ begin
+ Bundler.setup(:default)
+ rescue Bundler::BundlerError => e
+ STDERR.puts e.message
+ STDERR.puts "Run `bundle install` to install missing gems"
+ exit e.status_code
+ end
+ end
end
-require 'ronin/ui/command_line/commands/gen'
-require 'ronin/ui/command_line'
+lib_dir = File.join(root_dir,'lib')
+$LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
+require 'ronin/gen/gen'
+require 'ronin/ui/cli/commands/gen'
+
if (ARGV.length > 0 && ARGV.first[0..0] != '-')
- ARGV[0] = "gen_#{ARGV.first}"
+ name = ARGV.shift
- Ronin::UI::CommandLine.start
+ begin
+ Ronin::Gen.generator(name).start
+ rescue Ronin::Gen::UnknownGenerator
+ STDERR.puts "ronin-gen: unknown generator #{name}"
+ STDERR.puts "ronin-gen: run 'ronin-gen' for a list of generators"
+ exit -1
+ end
else
- Ronin::UI::CommandLine::Commands::Gen.start
+ Ronin::UI::CLI::Commands::Gen.start
end