# File lib/templater/cli/generator.rb, line 31
      def run(arguments)
        generator_class = @generator_class # FIXME: closure wizardry, there has got to be a better way than this?
        
        @options = Templater::CLI::Parser.parse(arguments) do |opts, options|
          opts.separator "Options specific for this generator:"
          # the reason this is reversed is so that the 'main' generator will always have the last word
          # on the description of the option
          generator_class.generators.reverse.each do |generator|
            # Loop through this generator's options and add them as valid command line options
            # so that they show up in help messages and such
            generator.options.each do |option|
              name = option.name.to_s.gsub('_', '-')
              if option.options[:as] == :boolean
                opts.on("--#{name}", option.options[:desc]) do |s|
                  options[option.name] = s
                end
              else
                opts.on("--#{name}=value", option.options[:desc]) do |s|
                  options[option.name] = s.gsub('-', '_').to_sym
                end
              end
            end
          end
        end

        self.help if @options[:help]
        self.version if @options[:version]

        # Try to instantiate a generator, if the arguments to it were incorrect: show a help message
        begin
          @generator = @generator_class.new(@destination_root, @options, *arguments)
        rescue Templater::ArgumentError => e
          if @options[:debug]
            raise e
          else
            self.help
          end
        end

        if @options[:pretend] 
          puts "Generating with #{@generator_name} generator (just pretending):"
        else
          puts "Generating with #{@generator_name} generator:" 
        end
        step_through_templates

        # Run hooks
        unless @options[:pretend]
          @generator.after_run
          @generator.after_generation unless @options[:delete]
          @generator.after_deletion   if     @options[:delete]
        end
      end