lib/rubygems/version_option.rb
##
# Add the --version option to the option parser.
Add the --version option to the option parser.
Add the -- version option to the option parser .
def add_version_option(task = command, *wrap)
    Gem::OptionParser.accept Gem::Requirement do |value|
      Gem::Requirement.new(*value.split(/\s*,\s*/))
    end
    add_option('-v', '--version VERSION', Gem::Requirement,
               "Specify version of gem to #{task}", *wrap) do
                 |value, options|
      if options[:version] && !options[:version].none?
        options[:version].concat([value])
      else
        options[:version] = value
      end
      explicit_prerelease_set = !options[:explicit_prerelease].nil?
      options[:explicit_prerelease] = false unless explicit_prerelease_set
      options[:prerelease] = value.prerelease? unless
        options[:explicit_prerelease]
    end
  end
def add_version_option ( task = command , * wrap ) Gem :: OptionParser . accept Gem :: Requirement do | value | Gem :: Requirement . new ( * value . split ( / \s *, \s * / ) ) end add_option ( '-v' , '--version VERSION' , Gem :: Requirement , "Specify version of gem to #{task}" , * wrap ) do | value , options | if options [ :version ] && ! options [ :version ] . none? options [ :version ] . concat ( [ value ] ) else options [ :version ] = value end explicit_prerelease_set = ! options [ :explicit_prerelease ] . nil? options [ :explicit_prerelease ] = false unless explicit_prerelease_set options [ :prerelease ] = value . prerelease? unless options [ :explicit_prerelease ] end end
Add the --version option to the option parser.
Add the -- version option to the option parser .
# Allow handling for multiple --version operators
task
<not_specific>
command
<not_specific>
wrap
<not_specific>