class GithubEventsExport::Options

Parse CLI options

Attributes

args[R]

Public Class Methods

new(args) click to toggle source
# File lib/github_events_export/options.rb, line 8
def initialize(args)
  @args = args
end

Public Instance Methods

[](key) click to toggle source
# File lib/github_events_export/options.rb, line 12
def [](key)
  parse[key]
end
to_hash() click to toggle source
# File lib/github_events_export/options.rb, line 16
def to_hash
  parse
end

Private Instance Methods

option_parser() click to toggle source
# File lib/github_events_export/options.rb, line 30
def option_parser
  OptionParser.new do |opts|
    opts.banner = 'Usage: github-events-export [options]'
    opts.on('--token=TOKEN', 'GitHub Access Token')
    opts.on('-v', '--version', 'Print version')
    opts.on('-h', '--help', 'Prints this help') do
      puts opts
      exit 1
    end
  end
end
parse() click to toggle source
# File lib/github_events_export/options.rb, line 24
def parse
  options = {}
  option_parser.parse!(args, into: options)
  options
end