Sha256: 38e87e0f0e3d15a0ead8d331cf201c0289f34f07bfbcce212ad5f41b2d616399
Contents?: true
Size: 1.47 KB
Versions: 14
Compression:
Stored size: 1.47 KB
Contents
#!/usr/bin/ruby require 'optparse' options = {} optparse = OptionParser.new do |opts| opts.banner = "Usage: spire -c app" opts.on('-h', '--help', 'Displays this usage screen') do puts optparse exit end opts.on('-g', '--generate controller', 'Generates a new view controller') do |params| options[:generate] = params end opts.on('-c', '--create project', 'Creates a new app/project with given name.') do |params| options[:create] = params end end begin optparse.parse! rescue OptionParser::InvalidOption puts optparse exit 1 end if options[:generate] if File.directory? 'app/controllers' controller_value = options[:generate].capitalize puts "Generating..." controller = File.new("app/controllers/#{controller_value}Controller.rb", "w+") if controller controller.write("class #{controller_value} < Spire::MainController \n\t def index \n\t \t render :text => 'Hello, new controller!' \n\t end \nend ") controller.close puts "Created controller file: #{controller_value}Controller in app/controllers/" else puts "No file made, file could not be created for writing." end else puts "No app folder found to create a controller." end end if options[:create] unless Dir.exists?(options[:create]) system("git clone git://github.com/snicol/spire-base-app.git #{options[:create]}") end end unless options[:create] or options[:generate] puts "No arguments given. See `spire -h' for documentation." end
Version data entries
14 entries across 14 versions & 1 rubygems