diff --git a/bin/qw b/bin/qw index 51f994f..7b29498 100755 --- a/bin/qw +++ b/bin/qw @@ -8,9 +8,12 @@ require "qwandry" load('~/.qwandry/repositories.rb') if File.exists?('~/.qwandry/repositories.rb') opts = OptionParser.new do |opts| - opts.banner = "Usage: qwandry [options] name [version]" + opts.banner = "Usage: qwandry [options] name" opts.separator "" + opts.on("-r", "--repo LABEL", "Only search in repository LABEL") do |label| + @repository_label = label + end opts.separator "Known Repositories: #{@qwandry.repositories.keys.join(", ")}" opts.on("-e", "--editor EDITOR", "Use EDITOR to open the package") do |editor| @qwandry.editor = editor @@ -30,7 +33,7 @@ if ARGV.length != 1 end name = ARGV.pop -packages = @qwandry.find(name) +packages = @qwandry.find(name,@repository_label) package = nil case packages.length diff --git a/lib/qwandry/launcher.rb b/lib/qwandry/launcher.rb index 5a25b3b..cffe851 100644 --- a/lib/qwandry/launcher.rb +++ b/lib/qwandry/launcher.rb @@ -1,5 +1,5 @@ # Launcher is the core Qwandry class, it coordinates finding and launching -# a package. It is driven externaly by a UI. +# a package. It is driven externaly by a UI, for instance the `bin/qw`. module Qwandry class Launcher # The default editor to be used by Qwandry#launch. @@ -23,9 +23,10 @@ module Qwandry end # Searches all of the loaded repositories for `name` - def find(name) + def find(name,repository_label=nil) packages = [] @repositories.each do |label, repos| + next if repository_label && repository_label != label repos.each do |repo| packages.concat(repo.scan(name)) end @@ -33,7 +34,7 @@ module Qwandry packages end - # Launches a `package`, unless set, `editor` will check against the environment. + # Launches a `package`. Unless `editor` will check against the environment by default. def launch(package, editor=nil) editor ||= @editor || ENV['VISUAL'] || ENV['EDITOR'] system editor, *package.paths