Class: Jobim::CLI
- Inherits:
-
Object
- Object
- Jobim::CLI
- Defined in:
- lib/jobim/cli.rb
Overview
Command line interface for the Jobim application. Utilizes optparse to manage user arguments and populates a ‘Jobim::Settings` object.
Instance Attribute Summary collapse
-
#exit ⇒ Object
readonly
Returns the value of attribute exit.
-
#options ⇒ Hash
readonly
Memoized, lazy accessor for the options hash.
-
#parser ⇒ OptionParser
readonly
Memoized accessor for the ‘OptionParser` object.
-
#settings ⇒ Jobim::Settings
readonly
Memoized, lazy accessor for the settings object.
Instance Method Summary collapse
-
#help ⇒ String
Help documentation of the program.
-
#parse(args) ⇒ NilClass
Runs the parse method of the value returned by the ‘#parser` method.
Instance Attribute Details
#exit ⇒ Object (readonly)
Returns the value of attribute exit.
6 7 8 |
# File 'lib/jobim/cli.rb', line 6 def exit @exit end |
#options ⇒ Hash (readonly)
Memoized, lazy accessor for the options hash.
18 19 20 |
# File 'lib/jobim/cli.rb', line 18 def @options end |
#parser ⇒ OptionParser (readonly)
Memoized accessor for the ‘OptionParser` object. It is generated only when called upon. See the readme for information about the command flags.
34 35 36 |
# File 'lib/jobim/cli.rb', line 34 def parser @parser end |
#settings ⇒ Jobim::Settings (readonly)
Memoized, lazy accessor for the settings object.
11 12 13 |
# File 'lib/jobim/cli.rb', line 11 def settings @settings end |
Instance Method Details
#help ⇒ String
Help documentation of the program.
105 106 107 |
# File 'lib/jobim/cli.rb', line 105 def help parser.to_s end |
#parse(args) ⇒ NilClass
Runs the parse method of the value returned by the ‘#parser` method. This is done in a manner destructive to the passed args `Array`. If there is a trailing value after parsing is completed it is treated as the `:dir` option.
95 96 97 98 99 100 |
# File 'lib/jobim/cli.rb', line 95 def parse(args) parser.parse!(args) [:dir] = File.(args[0]) if args.length == 1 nil end |