Added optional custom repository.rb and made qwandry pick the package if there is only one match.
This commit is contained in:
parent
a9152515c6
commit
c59a690643
26
qwandry.rb
26
qwandry.rb
@ -62,10 +62,16 @@ module Qwandry
|
||||
end
|
||||
end
|
||||
|
||||
def launch(package)
|
||||
`mate #{package.paths.join(' ')}`
|
||||
end
|
||||
module_function :launch
|
||||
|
||||
end
|
||||
|
||||
if __FILE__ == $0
|
||||
load('repositories.rb')
|
||||
load('~/.qwandry/repositories.rb') if File.exists?('~/.qwandry/repositories.rb')
|
||||
|
||||
opts = OptionParser.new do |opts|
|
||||
opts.banner = "Usage: qwandry [options] name [version]"
|
||||
@ -93,13 +99,19 @@ if __FILE__ == $0
|
||||
packages.concat(repo.scan(name))
|
||||
end
|
||||
end
|
||||
|
||||
package = nil
|
||||
if packages.length == 1
|
||||
package = packages.first
|
||||
else
|
||||
packages.each_with_index do |package, index|
|
||||
puts "%3d. %s" % [index+1, package.name]
|
||||
end
|
||||
|
||||
packages.each_with_index do |package, index|
|
||||
puts " #{index+1}. #{package.name}"
|
||||
print ">> "
|
||||
index = gets.to_i-1
|
||||
package = packages[index]
|
||||
end
|
||||
|
||||
print ">> "
|
||||
index = gets.to_i-1
|
||||
package = packages[index]
|
||||
`mate #{package.paths.join(' ')}` if package
|
||||
|
||||
Qwandry.launch package if package
|
||||
end
|
@ -1,19 +1,10 @@
|
||||
@repositories = Hash.new{|h,k| h[k] = []}
|
||||
|
||||
def which(bin)
|
||||
`which #{bin}`.chomp
|
||||
end
|
||||
|
||||
def add(label, path, repository_type=Qwandry::FlatRepository)
|
||||
label = label.to_s
|
||||
@repositories[label] << repository_type.new(label, path)
|
||||
end
|
||||
|
||||
#if which('ruby') == '/Users/adam/.rvm/rubies/ruby-1.9.1-p378/bin/ruby'
|
||||
# add :gem, '/Users/adam/.rvm/gems/ruby-1.9.1-p378/gems/'
|
||||
# add :ruby, '/Users/adam/.rvm/rubies/ruby-1.9.1-p378/lib/ruby/1.9.1/'
|
||||
#end
|
||||
|
||||
# Add gem repositories:
|
||||
# Using the ruby load paths, determine the common gem root paths, and add those.
|
||||
# This assumes gem paths look like:
|
||||
|
Loading…
Reference in New Issue
Block a user