Class: Vmail::SendOptions
Constant Summary
Constants inherited from Options
Options::DEFAULT_CONTACTS_FILENAME
Instance Attribute Summary
Attributes inherited from Options
Instance Method Summary collapse
Methods inherited from Options
Constructor Details
This class inherits a constructor from Vmail::Options
Instance Method Details
#parse(argv) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/vmail/send_options.rb', line 6 def parse(argv) OptionParser.new do |opts| opts. = "Usage: vmailsend" opts.separator "" opts.separator "Specific options:" opts.on("-c", "--config path", String, "Path to config file") do |config_file| @config_file = config_file end opts.on("-v", "--version", "Show version (identical to vmail version)") do require 'vmail/version' puts "vmail #{Vmail::VERSION}\nCopyright 2010 Daniel Choi under the MIT license" exit end opts.on("-h", "--help", "Show this message") do puts opts exit end opts.separator "" opts.separator INSTRUCTIONS begin opts.parse!(argv) if @config_file && File.exists?(@config_file) puts "Using config file #{@config_file}" else puts <<EOF Missing config file! #{INSTRUCTIONS} EOF exit(1) end @config = YAML::load(File.read(@config_file)) if @config['password'].nil? @config['password'] = ask("Enter gmail password (won't be visible & won't be persisted):") {|q| q.echo = false} end rescue OptionParser::ParseError => e STDERR.puts e., "\n", opts end end end |