#!/usr/bin/env ruby =begin backpack (c) 2008 Grégoire Lejeune =end require 'rubygems' require 'optparse' require 'backpack' options = {} opts = OptionParser.new do |opts| opts.banner = "Usage: backpack [options] plugin_name" opts.define_head "#{File.basename($0)} is a plugin generator for bivouac" opts.separator "" opts.separator "Specific options:" opts.on("-g", "--generator NAME:TYPE,...", "Generator list. TYPE must be 'view' or 'controller'") { |list| options[:generators] = list.split( "," ).map{ |g| g.strip }.map{ |g| g.split(":").map{|t| t.strip}} } opts.on("-c", "--no-controller-helpers", "Do not create controller helper") { |noch| options[:noch] = noch } opts.on("-v", "--no-view-helpers", "Do not create view helper") { |novh| options[:novh] = novh } opts.separator "" opts.separator "Common options:" # No argument, shows at tail. This will print an options summary. # Try it and see! opts.on_tail("-?", "--help", "Show this message") do puts opts exit end # Another typical switch to print the version. opts.on_tail("-V", "--version", "Show version") do class << Gem; attr_accessor :loaded_specs; end puts Gem.loaded_specs['backpack'].version exit end end # Parse options opts.parse! ARGV if ARGV.length < 1 puts opts exit end # Get APP name name = ARGV.dup Backpack.new( options, name[0] ).run()