Class: CreateConfigParser

Inherits:
Object
  • Object
show all
Defined in:
lib/imap-feeder/createconfigparser.rb

Class Method Summary collapse

Class Method Details

.parse(args) ⇒ Object



5
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
# File 'lib/imap-feeder/createconfigparser.rb', line 5

def self.parse(args)
  options = OpenStruct.new

  opts = OptionParser.new do |opts|
    opts.banner = <<EOF
Usage: #{$0} [options] to create or check your configuration
or     #{$0} SETTINGS_FILE to run the script
EOF

    opts.on("-c", "--check-settings FEEDS_FILE",
            "Check a feed file") do |file|
      options.check = file
    end

    opts.on("-r", "--imap-root [FOLDER]",
            "Use this as the root folder for all feeds") do |folder|
      options.folder = folder
    end

    opts.on("-n", "--new-config [OPML_FILE]",
            "Create a new configuration") do |file|
      options.create = true
      options.create_file = file
    end

    opts.on("-p", "--pretend",
            "Don't do anything, just pretend. " +
            "Prints new items to the console.") do |pretend|
      options.pretend = pretend
    end
  end
  opts.parse!(args)

  options
end