Class: Reviewer::Arguments
- Inherits:
-
Object
- Object
- Reviewer::Arguments
- Defined in:
- lib/reviewer/arguments.rb,
lib/reviewer/arguments/tags.rb,
lib/reviewer/arguments/files.rb,
lib/reviewer/arguments/keywords.rb
Overview
Handles option parsing for ‘rvw` and `fmt` commands
Defined Under Namespace
Classes: Files, Keywords, Tags
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
-
#files ⇒ Arguments::Files
The file arguments collected from the command line via the ‘-f` or `–files` flag.
-
#initialize(options = ARGV) ⇒ self
constructor
A catch all for aguments passed to reviewer via the command-line so they can be interpreted and made available via the relevant classes.
-
#keywords ⇒ Arguments::Keywords
The leftover arguments collected from the command line without being associated with a flag.
-
#tags ⇒ Arguments::Tags
The tag arguments collected from the command line via the ‘-t` or `–tags` flag.
-
#to_h ⇒ Hash
(also: #inspect)
Converts the arguments to a hash for versatility.
Constructor Details
#initialize(options = ARGV) ⇒ self
A catch all for aguments passed to reviewer via the command-line so they can be interpreted
and made available via the relevant classes.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/reviewer/arguments.rb', line 37 def initialize( = ARGV) @output = Output.new @options = Slop.parse 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.help VERSION exit end opts.on '-h', '--help', 'print the help' do @output.help opts exit end end end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
22 23 24 |
# File 'lib/reviewer/arguments.rb', line 22 def @options end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
24 25 26 |
# File 'lib/reviewer/arguments.rb', line 24 def output @output end |
Instance Method Details
#files ⇒ Arguments::Files
The file arguments collected from the command line via the ‘-f` or `–files` flag
77 78 79 |
# File 'lib/reviewer/arguments.rb', line 77 def files @files ||= Arguments::Files.new(provided: [:files]) end |
#keywords ⇒ Arguments::Keywords
The leftover arguments collected from the command line without being associated with a flag
84 85 86 |
# File 'lib/reviewer/arguments.rb', line 84 def keywords @keywords ||= Arguments::Keywords.new(.arguments) end |
#tags ⇒ Arguments::Tags
The tag arguments collected from the command line via the ‘-t` or `–tags` flag
70 71 72 |
# File 'lib/reviewer/arguments.rb', line 70 def @tags ||= Arguments::Tags.new(provided: [:tags]) end |
#to_h ⇒ Hash Also known as: inspect
Converts the arguments to a hash for versatility
58 59 60 61 62 63 64 |
# File 'lib/reviewer/arguments.rb', line 58 def to_h { files: files.raw, tags: .raw, keywords: keywords.raw } end |