An option of a command line. Options are read "automatically" using their declaration information defined with externalized strings (resources) accessed through ALib Enum Records associated with enum elements of enum custom types.
However, such automatic read is limited due to the fact, that the simple values and flags defined with OptionDecl, cannot provide the flexibility needed to perfectly parse options with a complex syntax.
In this case, the way out is to use custom code that invokes ReadOptions and then processes all options that may have remaining arguments left in the list. Using field Position further arguments may be consumed from CommandLine::ArgsLeft.
Note, "processing all options" may mean a nested loop. The outer is over the option types of OptionsFound, the inner is over the vector of options per type.
Definition at line 348 of file arguments.inl.
Public Field Index: | |
| ListMA< String, Recycling::Shared > | Args |
| Arguments belonging to this option. | |
| OptionDecl * | Declaration = nullptr |
| The declaration struct. | |
Public Field Index: inherited from alib::cli::Parsed | |
| CommandLine * | CmdLine |
| The cli command line. | |
| integer | ConsumedArguments |
| integer | Position |
Public Method Index: | |
| Option (CommandLine *cmdLine) | |
| ALIB_DLL bool | Read (OptionDecl &decl, String &arg, const integer argNo) |
Public Method Index: inherited from alib::cli::Parsed | |
| Parsed (CommandLine *cmdLine) | |
Arguments belonging to this option.
Definition at line 354 of file arguments.inl.
| OptionDecl* alib::cli::Option::Declaration = nullptr |
The declaration struct.
Definition at line 351 of file arguments.inl.
|
inline |
Constructor
| cmdLine | The command line main object. |
Definition at line 464 of file commandline.inl.
| bool alib::cli::Option::Read | ( | OptionDecl & | decl, |
| String & | arg, | ||
| const integer | argNo ) |
Tries to read the object from the current CLI arg(s).
| decl | The declaration used for reading. |
| arg | The argument string starting with one or two hyphens. |
| argNo | The position of reading. |
true on success, false otherwise. Definition at line 64 of file arguments.cpp.