2 # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
4 # See LICENSE.txt for permissions.
8 require 'rubygems/security'
11 # Mixin methods for install and update options for Gem::Commands
12 module Gem::InstallUpdateOptions
14 # Add the install/update options to the option parser.
15 def add_install_update_options
16 OptionParser.accept Gem::Security::Policy do |value|
17 value = Gem::Security::Policies[value]
18 raise OptionParser::InvalidArgument, value if value.nil?
22 add_option(:"Install/Update", '-i', '--install-dir DIR',
23 'Gem repository directory to get installed',
24 'gems') do |value, options|
25 options[:install_dir] = File.expand_path(value)
28 add_option(:"Install/Update", '-n', '--bindir DIR',
29 'Directory where binary files are',
30 'located') do |value, options|
31 options[:bin_dir] = File.expand_path(value)
34 add_option(:"Install/Update", '-d', '--[no-]rdoc',
35 'Generate RDoc documentation for the gem on',
36 'install') do |value, options|
37 options[:generate_rdoc] = value
40 add_option(:"Install/Update", '--[no-]ri',
41 'Generate RI documentation for the gem on',
42 'install') do |value, options|
43 options[:generate_ri] = value
46 add_option(:"Install/Update", '-E', '--[no-]env-shebang',
47 "Rewrite the shebang line on installed",
48 "scripts to use /usr/bin/env") do |value, options|
49 options[:env_shebang] = value
52 add_option(:"Install/Update", '-f', '--[no-]force',
53 'Force gem to install, bypassing dependency',
54 'checks') do |value, options|
55 options[:force] = value
58 add_option(:"Install/Update", '-t', '--[no-]test',
59 'Run unit tests prior to installation') do |value, options|
60 options[:test] = value
63 add_option(:"Install/Update", '-w', '--[no-]wrappers',
64 'Use bin wrappers for executables',
65 'Not available on dosish platforms') do |value, options|
66 options[:wrappers] = value
69 add_option(:"Install/Update", '-P', '--trust-policy POLICY',
70 Gem::Security::Policy,
71 'Specify gem trust policy') do |value, options|
72 options[:security_policy] = value
75 add_option(:"Install/Update", '--ignore-dependencies',
76 'Do not install any required dependent gems') do |value, options|
77 options[:ignore_dependencies] = value
80 add_option(:"Install/Update", '-y', '--include-dependencies',
81 'Unconditionally install the required',
82 'dependent gems') do |value, options|
83 options[:include_dependencies] = value
86 add_option(:"Install/Update", '--[no-]format-executable',
87 'Make installed executable names match ruby.',
88 'If ruby is ruby18, foo_exec will be',
89 'foo_exec18') do |value, options|
90 options[:format_executable] = value
93 add_option(:"Install/Update", "--development",
94 "Install any additional development",
95 "dependencies") do |value, options|
96 options[:development] = true
100 # Default options for the gem install command.
101 def install_update_defaults_str
102 '--rdoc --no-force --no-test --wrappers'