From cf69064893f892f9d43a9c58dbf86b15df19fd64 Mon Sep 17 00:00:00 2001 From: Adam Sanderson Date: Sun, 8 Aug 2010 21:15:20 -0700 Subject: [PATCH] named repositories --- qwandry.rb | 15 +++++++++++---- repositories.rb | 3 ++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/qwandry.rb b/qwandry.rb index fcda111..f8e9eac 100755 --- a/qwandry.rb +++ b/qwandry.rb @@ -16,7 +16,10 @@ require 'optparse' module Qwandry class Repository - def initialize(path) + attr_reader :name + + def initialize(name, path) + @name = name @path = path.chomp('/') end @@ -41,6 +44,7 @@ module Qwandry results << package(File.basename(path), [path]) end end + results end end @@ -61,12 +65,17 @@ module Qwandry end if __FILE__ == $0 + load('repositories.rb') + opts = OptionParser.new do |opts| opts.banner = "Usage: qwandry [options] name [version]" opts.separator "" opts.separator "Known Repositories:" - # ... + @repositories.keys.each do |repo_label| + opts.separator " #{repo_label}" + end + end opts.parse! ARGV @@ -76,8 +85,6 @@ if __FILE__ == $0 exit(-1) end - load('repositories.rb') - name = ARGV.pop packages = [] diff --git a/repositories.rb b/repositories.rb index dd52cac..5a98983 100644 --- a/repositories.rb +++ b/repositories.rb @@ -5,7 +5,8 @@ def which(bin) end def add(label, path, repository_type=Qwandry::FlatRepository) - @repositories[label.to_s] << repository_type.new(path) + 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'