Sha256: 6999cb4a62ef0c2c640ca1451c35f6906c6d746aaba854bf16619a34622dc841

Contents?: true

Size: 1.38 KB

Versions: 6

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

6 entries across 6 versions & 1 rubygems

Version Path
vmail-2.9.4 lib/vmail/send_options.rb
vmail-2.9.3 lib/vmail/send_options.rb
vmail-2.9.2 lib/vmail/send_options.rb
vmail-2.9.1 lib/vmail/send_options.rb
vmail-2.9.0 lib/vmail/send_options.rb
vmail-2.8.9 lib/vmail/send_options.rb