FORCES
FORtran lib for Comp. Env. Sys.
|
Module to parse command line arguments. More...
Go to the source code of this file.
Data Types | |
module | mo_cli::option |
This is a container for a single command line option. More... | |
module | mo_cli::cli_parser |
This is a parser for command line arguments. More... | |
Modules | |
module | mo_cli |
Module to parse command line arguments. | |
Functions/Subroutines | |
type(cli_parser) function | mo_cli::new_cli_parser (prog, description, add_help_option, add_version_option, version, add_logger_options) |
Create a new cli_parser. | |
type(option) function | mo_cli::new_option (name, s_name, help, has_value, value_name, default, required, blank, repeated) |
Create a new option. | |
subroutine | mo_cli::add_option (self, name, s_name, help, has_value, value_name, default, required, blank, repeated) |
Add a new option to the cli_parser. | |
integer(i4) function | mo_cli::cnt_options (self) |
Get option count from the cli_parser. | |
logical function | mo_cli::is_given_arg (self, arg) |
check if this option is the given argument. | |
integer(i4) function | mo_cli::get_option_index (self, name, long, short, raise_error) |
Get the option index from cli_parser by name. | |
type(option) function | mo_cli::get_option (self, name) |
Get an option from cli_parser by name. | |
logical function | mo_cli::option_was_read (self, name) |
Whether the option was read by the cli_parser given by name. | |
integer(i4) function | mo_cli::option_read_count (self, name) |
Read count for the option in the cli_parser given by name. | |
logical function | mo_cli::has_option (self, name) |
Whether the option is defined in cli_parser given by name. | |
integer(i4) function | mo_cli::get_blank_option_index (self) |
Get the index of the blank option. | |
character(:) function, allocatable | mo_cli::option_value (self, name) |
Get the parsed value from an option by name from the cli_parser. | |
subroutine | mo_cli::print_info (self) |
Print info for an option. | |
subroutine | mo_cli::print_help (self) |
Print help message for the cli_parser. | |
subroutine | mo_cli::parse (self) |
Parse the given command line arguments with the cli_parser. | |
subroutine | mo_cli::parse_arg (arg, names, counts) |
Parse given argument. | |
integer(i4) function | mo_cli::findchar (array, chr) |
Module to parse command line arguments.
A simple parser for command line arguments. You can define options and then parse the given command. Option can be with or without passed values and they can be set as required.
The following example demonstrates the functionality:
You can call the program with:
As you see, you can automatically create help and version options:
COPYING
and COPYING.LESSER
provided with this software. The complete GNU license text can also be found at http://www.gnu.org/licenses/. Definition in file mo_cli.f90.