Simple command that allows users to easily create a new application based on the prototype that ships with Ramaze.
Usage:
ramaze create blog
@author Yorick Peterse @since 21-07-2011
The description of this command as shown in the global help message.
The banner of this command.
Creates a new instance of the command and sets the options for OptionParser.
@author Yorick Peterse @since 21-07-2011
# File lib/ramaze/bin/create.rb, line 40 40: def initialize 41: @options = { 42: :force => false 43: } 44: 45: @opts = OptionParser.new do |opt| 46: opt.banner = Banner 47: opt.summary_indent = ' ' 48: 49: opt.separator "\nOptions:\n" 50: 51: opt.on('-f', '--force', 'Overwrites existing directories') do 52: @options[:force] = true 53: end 54: 55: opt.on('-h', '--help', 'Shows this help message') do 56: puts @opts 57: exit 58: end 59: end 60: end
Runs the command based on the specified command line arguments.
@author Yorick Peterse @since 21-07-2011 @param [Array] argv Array containing all command line arguments.
# File lib/ramaze/bin/create.rb, line 69 69: def run(argv = []) 70: @opts.parse!(argv) 71: 72: path = argv.delete_at(0) 73: proto = __DIR__('../../proto') 74: 75: abort 'You need to specify a name for your application' if path.nil? 76: 77: if File.directory?(path) and @options[:force] === false 78: abort 'The specified application already exists, use -f to overwrite it' 79: end 80: 81: if File.directory?(path) and @options[:force] === true 82: FileUtils.rm_rf(path) 83: end 84: 85: begin 86: FileUtils.cp_r(proto, path) 87: puts "The application has been generated and saved in #{path}" 88: rescue 89: abort 'The application could not be generated' 90: end 91: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.