Options - a Perl module for handling programm arguments, commandline in and output inclusive login requests
use Options;
This module contains functions that are used to get and set simply program arguments from commanline and small handling for commandline in and output. The following options are predefined for defining the argument types:
my $option_options = {
"" => "",
"!" => "",
"=s" => "=STRING",
":s" => "[=STRING]",
"=i" => "=INTEGER",
":i" => "[=INTEGER]",
"=f" => "=FLOAT",
":f" => "[=FLOAT]",
};
And in addition the predefined arguments:
register(
["help", "h", "", "display this help"],
["verbose", "v", "", "print verbose messages"],
["log", "l", ":s", "print messages to file instead of stdout"],#, "log filename", "$0.log"],
["not", "n", "", "do not perform any actual work"],
);
interview
$helpcontext = Options::help();
This function returns a formattedt string containing the help description of the program including all the options defined by @options.
interview
$config = Options::parse($usagedescrion, $quiet);
This function parse all the options and setting the usagedescription for help. If the quiet option is set, there will be no asks for inputtting arguments is accessed.
interview
Options::ask_out();
After the quiet Optins::parse you will need to complete the inputs on commandline ? Thats this function is created for.
interview
Options::print_out($outputstring);
Prints the given string in dependency of verbosity and logging switches.
interview
$value = Options::get_stdin($prompt, $default);
For the completion of getting values this ask at stdin for the value with the prompt and the default value concatenate in [] after. the return is the well filtered value.
interview
Options::ask($name, $prompt, $default);
wrapper around get_stdin., which get value from stdin if in $config the value is not set. $config->{$name} is updated. $prompt and $default for the default value.
interview
Options::ask_secret($name, $prompt, $default);
wrapper around get_stdin., which get value from stdin if in $config the value is not set. $config->{$name} is updated. $prompt and $default for the default value. But the output is hidden for secret values like passwords.
Hey! The above document had some coding errors, which are explained below:
=over without closing =back