Rewrite the "gem-*" commands to use :arguments_required.
This commit is contained in:
parent
ac63605180
commit
1ae359c3e6
|
@ -3,8 +3,7 @@ class Pry
|
||||||
|
|
||||||
Gems = Pry::CommandSet.new do
|
Gems = Pry::CommandSet.new do
|
||||||
|
|
||||||
command "gem-install", "Install a gem and refresh the gem cache." do |gem|
|
command "gem-install", "Install a gem and refresh the gem cache.", :arguments_required => 1 do |gem|
|
||||||
if gem
|
|
||||||
if File.writable? Gem.dir
|
if File.writable? Gem.dir
|
||||||
installer = Gem::DependencyInstaller.new :install_dir => Gem.dir
|
installer = Gem::DependencyInstaller.new :install_dir => Gem.dir
|
||||||
installer.install gem
|
installer.install gem
|
||||||
|
@ -18,18 +17,11 @@ class Pry
|
||||||
end
|
end
|
||||||
|
|
||||||
Gem.refresh
|
Gem.refresh
|
||||||
else
|
|
||||||
output.puts "gem-install requires the name of a gem as an argument."
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
command "gem-cd", "Change working directory to specified gem's directory." do |gem|
|
command "gem-cd", "Change working directory to specified gem's directory.", :arguments_required => 1 do |gem|
|
||||||
if gem
|
|
||||||
spec = Gem.source_index.find_name(gem).first
|
spec = Gem.source_index.find_name(gem).first
|
||||||
spec ? Dir.chdir(spec.full_gem_path) : output.puts("Gem `#{gem}` not found.")
|
spec ? Dir.chdir(spec.full_gem_path) : output.puts("Gem `#{gem}` not found.")
|
||||||
else
|
|
||||||
output.puts 'gem-cd requires the name of a gem as an argument.'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue