Sha256: 15fa629766638ebf99bbffd779e0a63ddafbf8b10e304e4c83ae946b81f4b8f2

Contents?: true

Size: 744 Bytes

Versions: 1

Compression:

Stored size: 744 Bytes

Contents

# frozen_string_literal: true

require 'optparse'

module GithubEventsExport
  # Parse CLI options
  class Options
    def initialize(args)
      @args = args
    end

    def [](key)
      parse[key]
    end

    def to_hash
      parse
    end

    private

    attr_reader :args

    def parse
      options = {}
      option_parser.parse!(args, into: options)
      options
    end

    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
github_events_export-0.1.0 lib/github_events_export/options.rb