2
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
4
# See LICENSE.txt for permissions.
9
# Mixin methods for --version and --platform Gem::Command options.
10
module Gem::VersionOption
12
# Add the --platform option to the option parser.
13
def add_platform_option(task = command, *wrap)
14
OptionParser.accept Gem::Platform do |value|
15
if value == Gem::Platform::RUBY then
18
Gem::Platform.new value
22
add_option('--platform PLATFORM', Gem::Platform,
23
"Specify the platform of gem to #{task}", *wrap) do
25
unless options[:added_platform] then
27
Gem.platforms << Gem::Platform::RUBY
28
options[:added_platform] = true
31
Gem.platforms << value unless Gem.platforms.include? value
35
# Add the --version option to the option parser.
36
def add_version_option(task = command, *wrap)
37
OptionParser.accept Gem::Requirement do |value|
38
Gem::Requirement.new value
41
add_option('-v', '--version VERSION', Gem::Requirement,
42
"Specify version of gem to #{task}", *wrap) do
44
options[:version] = value