Class: Evernote::Jeeves::JeevesOptionsParser

Inherits:
Object
  • Object
show all
Defined in:
lib/evernote/jeeves.rb

Class Method Summary collapse

Class Method Details

.parse(args) ⇒ Object



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
51
52
53
54
55
# 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