Class: Inq::CLI
- Inherits:
-
Object
- Object
- Inq::CLI
- Defined in:
- lib/inq/cli.rb
Overview
Parses command-line arguments for inq.
Constant Summary collapse
- MissingArgument =
Class.new(OptionParser::MissingArgument)
- REPO_REGEXP =
/.+\/.+/
- DATE_REGEXP =
/\d\d\d\d-\d\d-\d\d/
Instance Attribute Summary collapse
-
#help_text ⇒ Object
readonly
Returns the value of attribute help_text.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
-
#parse(argv) ⇒ Hash
Parses an Array of command-line arguments into an equivalent Hash.
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
22 23 24 25 |
# File 'lib/inq/cli.rb', line 22 def initialize @options = nil @help_text = nil end |
Instance Attribute Details
#help_text ⇒ Object (readonly)
Returns the value of attribute help_text.
16 17 18 |
# File 'lib/inq/cli.rb', line 16 def help_text @help_text end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
16 17 18 |
# File 'lib/inq/cli.rb', line 16 def @options end |
Class Method Details
.parse(*args) ⇒ Object
18 19 20 |
# File 'lib/inq/cli.rb', line 18 def self.parse(*args) new.parse(*args) end |
Instance Method Details
#parse(argv) ⇒ Hash
Parses an Array of command-line arguments into an equivalent Hash.
The results of this can be used to control the behavior of the rest of the library.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/inq/cli.rb', line 34 def parse(argv) parser, = parse_main(argv) # Options that are mutually-exclusive with everything else. = {:help => true} if [:help] = {:version => true} if [:version] () @options = @help_text = parser.to_s self end |