Sha256: eb39ce101ae6b3e0d7691ea29958976e46b01f5e2353f66de99c502b49a62cda

Contents?: true

Size: 934 Bytes

Versions: 1

Compression:

Stored size: 934 Bytes

Contents

# frozen_string_literal: true

require 'slop'

# Handles option parsing for bin/review
module Reviewer
  class Arguments
    attr_accessor :options

    def initialize(options = ARGV)
      @options = Slop.parse options do |opts|
        opts.array '-f', '--files', 'a list of comma-separated files or paths', delimiter: ',', default: []
        opts.array '-t', '--tags', 'a list of comma-separated tags', delimiter: ',', default: []

        opts.on '-v', '--version', 'print the version' do
          puts VERSION
          exit
        end

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

    def files
      options[:files]
    end

    def tags
      options[:tags]
    end

    def arguments
      options.arguments
    end

    def keywords
      # TODO: Filter arguments to only for allowed keywords to be defined later.
      arguments
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
reviewer-0.1.1 lib/reviewer/arguments.rb