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
Public Class Methods
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
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
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
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