class Reviewer::Arguments

Handles option parsing for `rvw` and `fmt` commands

@example

`rvw`
`rvw -t ruby`
`rvw -f ./example.rb,./example_test.rb`
`rvw staged`
`rvw --files ./example.rb,./example_test.rb --tags syntax`
`rvw ruby staged`

Attributes

options[RW]
output[R]

Public Class Methods

new(options = ARGV) click to toggle source

A catch all for aguments passed to reviewer via the command-line. @param options = ARGV [Hash] options to parse and extract the relevant values for a run

@return [Reviewer::Arguments] the full collection of arguments provided via the command line

# File lib/reviewer/arguments.rb, line 30
def initialize(options = ARGV)
  @output = Output.new
  @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
      @output.info VERSION
      exit
    end

    opts.on '-h', '--help', 'print the help' do
      @output.info opts
      exit
    end
  end
end

Public Instance Methods

files() click to toggle source

The file arguments collected from the command line via the `-f` or `–files` flag

@return [Arguments::Files] an collection of the file arguments collected from the command-line

# File lib/reviewer/arguments.rb, line 70
def files
  @files ||= Arguments::Files.new(provided: options[:files])
end
inspect()
Alias for: to_h
keywords() click to toggle source

The leftover arguments collected from the command line without being associated with a flag

@return [Arguments::Keywords] an collection of the leftover arguments as keywords

# File lib/reviewer/arguments.rb, line 77
def keywords
  @keywords ||= Arguments::Keywords.new(options.arguments)
end
tags() click to toggle source

The tag arguments collected from the command line via the `-t` or `–tags` flag

@return [Arguments::Tags] an colelction of the tag arguments collected from the command-line

# File lib/reviewer/arguments.rb, line 63
def tags
  @tags ||= Arguments::Tags.new(provided: options[:tags])
end
to_h() click to toggle source

Converts the arguments to a hash for versatility

@return [Hash] The files, tags, and keywords collected from the command line options

# File lib/reviewer/arguments.rb, line 51
def to_h
  {
    files: files.raw,
    tags: tags.raw,
    keywords: keywords.raw
  }
end
Also aliased as: inspect