class Feedigest::OptionParser

Attributes

args[R]

Public Class Methods

new(args) click to toggle source
# File lib/feedigest/option_parser.rb, line 7
def initialize(args)
  @args = args
end

Public Instance Methods

options() click to toggle source
# File lib/feedigest/option_parser.rb, line 11
def options
  options = build_options
  parser = Slop::Parser.new(options)

  begin
    parser.parse(args).to_hash
  rescue Slop::Error => e
    puts "error: #{e.message}"
    puts
    puts options
    exit
  end
end

Private Instance Methods

build_options() click to toggle source
# File lib/feedigest/option_parser.rb, line 27
def build_options
  Slop::Options.new do |o|
    o.string(
      '--feeds',
      'path to file that contains a line-separated list of feed URLs',
      required: true
    )

    o.string '--filter', 'command to filter each feed with'

    o.string(
      '--config',
      'path to YAML configuration file',
      default: '~/.feedigest/config.yaml'
    )

    o.bool(
      '-n',
      '--dry-run',
      'print email instead of sending it',
      default: false
    )

    o.on '--version', 'print version' do
      puts Feedigest::VERSION
      exit
    end

    o.on '-h', '--help', 'print help' do
      puts o
      exit
    end
  end
end