# File lib/webby/apps/generator.rb, line 67
  def parse( args )
    opts = OptionParser.new
    opts.banner = 'Usage: webby-gen [options] template site'

    opts.separator ''
    opts.separator 'The webby-gen command is used to generate a site from a standard template.'
    opts.separator 'A new site can be created, or an existing site can be added to or updated.'

    opts.separator ''
    opts.on('-f', '--force',
            'overwrite files that already exist') {options[:collision] = :force}
    opts.on('-s', '--skip',
            'skip files that already exist') {options[:collision] = :skip}
    opts.on('-u', '--update',
            'update rake tasks for the site') {options[:update] = true}
    opts.on('-p', '--pretend',
            'run but do not make any changes') {options[:pretend] = true}

    opts.separator ''
    opts.on('-t', '--templates', 'list available templates') {
      ary = templates.map {|t| ::File.basename(t)}
      ary.delete 'webby'
      puts "\nAvailable Templates"
      puts "    #{ary.join(', ')}"
      puts
      exit
    }

    opts.separator ''
    opts.separator 'common options:'

    opts.on( '-h', '--help', 'show this message' ) {puts opts; exit}
    opts.on( '--version', 'show version' ) do
      puts "Webby #{::Webby::VERSION}"
      exit
    end

    # parse the command line arguments
    opts.parse! args
    tmpl, @site = args

    # if no site was given, see if there is a Sitefile in the current
    # directory
    if site.nil?
      self.site = '.' if test(?f, 'Sitefile')
    end

    # exit if comand line args are missing
    if site.nil? or tmpl.nil?
      puts opts
      exit 1
    end

    templates.each {|t| self.template = t if t =~ %r/\/#{tmpl}$/}
    if template.nil?
      puts opts
      abort "Could not find template '#{tmpl}'"
    end

    nil
  end