mirror of
https://github.com/ruby/ruby.git
synced 2025-08-23 21:14:23 +02:00
[rubygems/rubygems] add global flag (-C) to change execution directory
312fc36711
This commit is contained in:
parent
28a1743650
commit
08f6196bda
3 changed files with 62 additions and 5 deletions
|
@ -175,14 +175,20 @@ class Gem::CommandManager
|
|||
when "-v", "--version" then
|
||||
say Gem::VERSION
|
||||
terminate_interaction 0
|
||||
when "-C" then
|
||||
args.shift
|
||||
start_point = args.shift
|
||||
if Dir.exist?(start_point)
|
||||
Dir.chdir(start_point) { invoke_command(args, build_args) }
|
||||
else
|
||||
alert_error clean_text("#{start_point} isn't a directory.")
|
||||
terminate_interaction 1
|
||||
end
|
||||
when /^-/ then
|
||||
alert_error clean_text("Invalid option: #{args.first}. See 'gem --help'.")
|
||||
terminate_interaction 1
|
||||
else
|
||||
cmd_name = args.shift.downcase
|
||||
cmd = find_command cmd_name
|
||||
cmd.deprecation_warning if cmd.deprecated?
|
||||
cmd.invoke_with_build_args args, build_args
|
||||
invoke_command(args, build_args)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -237,4 +243,11 @@ class Gem::CommandManager
|
|||
ui.backtrace e
|
||||
end
|
||||
end
|
||||
|
||||
def invoke_command(args, build_args)
|
||||
cmd_name = args.shift.downcase
|
||||
cmd = find_command cmd_name
|
||||
cmd.deprecation_warning if cmd.deprecated?
|
||||
cmd.invoke_with_build_args args, build_args
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue