Sha256: 8e62d2bb66719c1b8f918bf2b87d86d8b1b67070ec3672fbcfa746f73cc29a33

Contents?: true

Size: 1.38 KB

Versions: 7

Compression:

Stored size: 1.38 KB

Contents

require 'vmail/options'

module Vmail
  class SendOptions < Vmail::Options

    def parse(argv)
      OptionParser.new do |opts|
        opts.banner = "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.message, "\n", opts
        end

      end
    end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
vmail-2.9.11 lib/vmail/send_options.rb
vmail-2.9.10 lib/vmail/send_options.rb
vmail-2.9.9 lib/vmail/send_options.rb
vmail-2.9.8 lib/vmail/send_options.rb
vmail-2.9.7 lib/vmail/send_options.rb
vmail-2.9.6 lib/vmail/send_options.rb
vmail-2.9.5 lib/vmail/send_options.rb