| Module | Mixlib::CLI |
| In: |
lib/mixlib/cli/version.rb
lib/mixlib/cli.rb |
Adds a DSL for defining command line options and methods for parsing those options to the including class.
Mixlib::CLI does some setup in initialize, so the including class must call `super()` if it defines a custom initializer.
When included, Mixlib::CLI also extends the including class with its ClassMethods, which define the DSL. The primary methods of the DSL are ClassMethods#option, which defines a command line option, and ClassMethods#banner, which defines the "usage" banner.
Command line options are parsed by calling the instance method parse_options. After calling this method, the attribute config will contain a hash of `:option_name => value` pairs.
| VERSION | = | "1.4.0" |
| banner | [RW] | Banner for the option parser. If the option parser is printed, e.g., by `puts opt_parser`, this string will be used as the first line. |
| cli_arguments | [RW] | Any arguments which were not parsed and placed in "config"—the leftovers. |
| config | [RW] |
A Hash containing the values supplied by command line options.
The behavior and contents of this Hash vary depending on whether ClassMethods#use_separate_default_options is enabled. use_separate_default_options disabledAfter initialization, config will contain any default values defined via the mixlib-config DSL. When parse_options is called, user-supplied values (from ARGV) will be merged in. use_separate_default_options enabledAfter initialization, this will be an empty hash. When parse_options is called, config is populated only with user-supplied values. |
| default_config | [RW] |
If ClassMethods#use_separate_default_options
is enabled, this will be a Hash containing key value pairs of `:option_name
=> default_value` (populated during object initialization).
If use_separate_default_options is disabled, it will always be an empty hash. |
| opt_parser | [RW] | The option parser generated from the mixlib-cli DSL. Set to nil on initialize; when parse_options is called opt_parser is set to an instance of OptionParser. opt_parser can be used to print a help message including the banner and any CLI options via `puts opt_parser`. |
| options | [RW] | Gives the command line options definition as configured in the DSL. These are used by parse_options to generate the option parsing code. To get the values supplied by the user, see config. |
Create a new Mixlib::CLI class. If you override this, make sure you call super!
| *args<Array>: | The array of arguments passed to the initializer |
| object<Mixlib::Config>: | Returns an instance of whatever you wanted :) |