Subroutines in the Opts Package
The Opts package includes the following subroutines:
add_options
Adds custom options so that they can be submitted to parsing and validation. After the script has validated the options, the script can use them at run time.
Parameters
Returns
Returns nothing.
get_option
Retrieves the value of the specified built-in or custom option.
Parameters
Returns
Returns one of the following, depending upon the attributes defined for the option:
Return value of func (after execution) if a function is associated with the option
Undef if none of the above are specified
option_is_set
Checks whether an option has been explicitly set by a script or from the command line or whether the option has a default value or computed value (return value of a func).
Parameters
Returns
Boolean. Returns 1 (true) if the option value has been explicitly set. Returns 0 (false) if the option value is a default value, is null, or has not been explicitly set. For a discussion of Boolean, see vSphere SDK for Perl Programming Conventions.
parse
Reads options from the command line, an environment variable, or a configuration file and transforms the option into appropriate data structures for validation.
Parameters
No parameters.
Returns
Returns nothing. Displays an error message and quits if the parse operation is not successful. If you want to use a configuration file, call Opts::get_config() to make sure the file can be opened. See Opts::get_config().
validate
Ensures that input values (from the command line, an environment variable, or a configuration file) are complete, consistent, and valid.
Parameters
No parameters.
Returns
Returns nothing. It displays an error message and quits if the parse operation is not successful.
usage
Displays the help text message.
Parameters
No parameters.
Returns
Returns nothing.