Allow overiding the editor

This commit is contained in:
Adam Sanderson 2010-08-16 21:23:42 -07:00
parent c09b5c7988
commit c694a1608b
1 changed files with 12 additions and 8 deletions

View File

@ -11,7 +11,7 @@ require 'optparse'
# If only one Package matches, that Package will be opened # If only one Package matches, that Package will be opened
# If more than one Package matches, then the user will be prompted to pick one # If more than one Package matches, then the user will be prompted to pick one
# While any two Packages share the same name their parent dir is appended # While any two Packages share the same name their parent dir is appended
# If no Repository matches, then qwandry will exit with a -404 (repo not found) # If no Repository matches, then qwandry will exit with a 404 (repo not found)
# #
module Qwandry module Qwandry
@ -76,20 +76,24 @@ if __FILE__ == $0
opts = OptionParser.new do |opts| opts = OptionParser.new do |opts|
opts.banner = "Usage: qwandry [options] name [version]" opts.banner = "Usage: qwandry [options] name [version]"
opts.separator "" opts.separator ""
opts.separator "Known Repositories:"
@repositories.keys.each do |repo_label| opts.separator "Known Repositories: #{@repositories.keys.join(", ")}"
opts.separator " #{repo_label}" opts.on("-e", "--editor EDITOR", "Use EDITOR to open the package") do |editor|
@editor = editor
end end
opts.on_tail("-h", "--help", "Show this message") do
puts opts
exit
end
end end
opts.parse! ARGV opts.parse! ARGV
if ARGV.length != 1 if ARGV.length != 1
puts opts puts opts
exit(-1) exit(1)
end end
name = ARGV.pop name = ARGV.pop
@ -105,7 +109,7 @@ if __FILE__ == $0
case packages.length case packages.length
when 0 when 0
puts "No packages matched '#{name}'" puts "No packages matched '#{name}'"
exit 1 exit 404 # Package not found -- hehe, super lame.
when 1 when 1
package = packages.first package = packages.first
else else
@ -118,5 +122,5 @@ if __FILE__ == $0
package = packages[index] package = packages[index]
end end
Qwandry.launch package if package Qwandry.launch(package, @editor) if package
end end