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
16
qwandry.rb
16
qwandry.rb
@ -62,10 +62,16 @@ module Qwandry
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def launch(package)
|
||||||
|
`mate #{package.paths.join(' ')}`
|
||||||
|
end
|
||||||
|
module_function :launch
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if __FILE__ == $0
|
if __FILE__ == $0
|
||||||
load('repositories.rb')
|
load('repositories.rb')
|
||||||
|
load('~/.qwandry/repositories.rb') if File.exists?('~/.qwandry/repositories.rb')
|
||||||
|
|
||||||
opts = OptionParser.new do |opts|
|
opts = OptionParser.new do |opts|
|
||||||
opts.banner = "Usage: qwandry [options] name [version]"
|
opts.banner = "Usage: qwandry [options] name [version]"
|
||||||
@ -94,12 +100,18 @@ if __FILE__ == $0
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
package = nil
|
||||||
|
if packages.length == 1
|
||||||
|
package = packages.first
|
||||||
|
else
|
||||||
packages.each_with_index do |package, index|
|
packages.each_with_index do |package, index|
|
||||||
puts " #{index+1}. #{package.name}"
|
puts "%3d. %s" % [index+1, package.name]
|
||||||
end
|
end
|
||||||
|
|
||||||
print ">> "
|
print ">> "
|
||||||
index = gets.to_i-1
|
index = gets.to_i-1
|
||||||
package = packages[index]
|
package = packages[index]
|
||||||
`mate #{package.paths.join(' ')}` if package
|
end
|
||||||
|
|
||||||
|
Qwandry.launch package if package
|
||||||
end
|
end
|
@ -1,19 +1,10 @@
|
|||||||
@repositories = Hash.new{|h,k| h[k] = []}
|
@repositories = Hash.new{|h,k| h[k] = []}
|
||||||
|
|
||||||
def which(bin)
|
|
||||||
`which #{bin}`.chomp
|
|
||||||
end
|
|
||||||
|
|
||||||
def add(label, path, repository_type=Qwandry::FlatRepository)
|
def add(label, path, repository_type=Qwandry::FlatRepository)
|
||||||
label = label.to_s
|
label = label.to_s
|
||||||
@repositories[label] << repository_type.new(label, path)
|
@repositories[label] << repository_type.new(label, path)
|
||||||
end
|
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:
|
# Add gem repositories:
|
||||||
# Using the ruby load paths, determine the common gem root paths, and add those.
|
# Using the ruby load paths, determine the common gem root paths, and add those.
|
||||||
# This assumes gem paths look like:
|
# This assumes gem paths look like:
|
||||||
|
Loading…
Reference in New Issue
Block a user