protected Method

Options.add_general_options!(opt)

Adds general options like -h and —quiet. Usually don’t override.

Source Code

# File rails_generator/options.rb, line 119
def add_general_options!(opt)
  opt.separator ''
  opt.separator 'Rails Info:'
  opt.on('-v', '--version', 'Show the Rails version number and quit.')
  opt.on('-h', '--help', 'Show this help message and quit.') { |v| options[:help] = v }

  opt.separator ''
  opt.separator 'General Options:'

  opt.on('-p', '--pretend', 'Run but do not make any changes.') { |v| options[:pretend] = v }
  opt.on('-f', '--force', 'Overwrite files that already exist.') { options[:collision] = :force }
  opt.on('-s', '--skip', 'Skip files that already exist.') { options[:collision] = :skip }
  opt.on('-q', '--quiet', 'Suppress normal output.') { |v| options[:quiet] = v }
  opt.on('-t', '--backtrace', 'Debugging: show backtrace on errors.') { |v| options[:backtrace] = v }
  opt.on('-c', '--svn', 'Modify files with subversion. (Note: svn must be in path)') do
    options[:svn] = `svn status`.inject({}) do |opt, e|
      opt[e.chomp[7..-1]] = true
      opt
    end
  end
  opt.on('-g', '--git', 'Modify files with git. (Note: git must be in path)') do
    options[:git] = `git status`.inject({:new => {}, :modified => {}}) do |opt, e|
      opt[:new][e.chomp[14..-1]] = true if e =~ /new file:/
      opt[:modified][e.chomp[14..-1]] = true if e =~ /modified:/
      opt
    end
  end
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.