class Evernote::Jeeves::JeevesOptionsParser

Public Class Methods

parse(args) click to toggle source
# File lib/evernote/jeeves.rb, line 20
def self.parse(args)
  options = OpenStruct.new
  #defaults
  options.verbose = FALSE
  options.search = 'TODO'
  options.ignorecase = FALSE
  options.days = 7

  opts_parser = OptionParser.new do |opts|
    opts.banner = "Usage: jeeves.rb [options]"

    opts.on("-v", "--verbose", "Run verbosely") do |v|
      options.verbose = v
    end

    opts.on("-s", "--search s", String, "Search string to look for in notes.") do |s|
      options.search = s
    end

    opts.on("-i", "--ignorecase", "Search case-insensitively") do |i|
      options.ignorecase = Regexp::IGNORECASE
    end

    opts.on("-d", "--days N", Integer, "Number of days in the past to search.") do |d|
      options.days = d
    end

    opts.on_tail("-h", "--help", "Show this message") do
      puts opts
      exit
    end
  end

  opts_parser.parse!(args)
  options
end