Module: JRubyEnginize::Script
- Defined in:
- lib/script.rb
Overview
Commandline code refactored to keep the executables lean.
Class Method Summary collapse
-
.enginize ⇒ Object
Command line code for the
"jruby-enginize"executable.
Class Method Details
.enginize ⇒ Object
Command line code for the "jruby-enginize" executable. Call with "--help" to learn more. Checks for running on JRuby and having the Google AppEngine SDK around and forwards work to JRubyEnginize::Generator.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/script.rb', line 22 def self.enginize email = nil template = 'sinatra' path = nil prog = File.basename($0) =begin # Check for running with JRuby: The whole generator makes no sense if not # running with or at least for JRuby... begin java.lang.String rescue $stderr.puts "!!#{prog} makes only sense on JRuby systems. Please try again." exit(1) end =end # The AppEngine SDK has to be around, too. begin raise ArgumentError if not File.stat(`which appcfg.sh`.chop).executable? rescue Exception $stderr.puts "!!AppEngine SDK missing. Please retry after installing." exit(2) end = { :name => nil, :dryrun => false } OptionParser.new do |opt| opt. = "Usage: #{prog} [options] --email address dirname" opt.on('-e', '--email address', 'E-Mail address to publish app with') { |email| } opt.on('-t', '--template name', "Name of the template (defaults to #{template})") { |template| } opt.on('-n', '--name appname', 'Name of the app (defaults to dir basename)') { |name| [:name] = name } opt.on('-d', '--dry', 'Test run not really creating files') { [:dryrun] = true } opt.on('-T', '--templates', 'List available templates') { puts 'Supported templates:' JRubyEnginize::Generator.templates.each { |name| puts " #{name}" } exit(0) } begin opt.parse!(ARGV) raise 'missing directory name' if (path = ARGV.first).nil? or path.empty? raise 'directory already exists' if FileTest.exists? path raise 'unknown template' if not JRubyEnginize::Generator.templates.include? template raise 'missing e-mail address' if email.nil? or email.empty? rescue SystemExit exit(1) rescue Exception => exception $stderr.puts "!!#{exception}\n\n" opt.parse!(['--help']) exit(3) end end JRubyEnginize::Generator.new(email, path, template, ).run end |