8#if !defined(ALIB_C20_MODULES) || ((ALIB_C20_MODULES != 0) && (ALIB_C20_MODULES != 1))
9# error "Symbol ALIB_C20_MODULES has to be given to the compiler as either 0 or 1"
19 import ALib.Characters.Functions;
21 import ALib.Strings.Tokenizer;
22 import ALib.EnumRecords.Bootstrap;
43 for(
auto* paramDecl :
CmdLine.ParameterDecls )
51 "Parameter named \"{}\" not found while loading resources of command \"{}\".",
57 if( param->Name().Equals<
NC>( name ) )
68 auto argsLeft =
CmdLine->ArgsLeft.size() -1;
74 if( valueSeparator > 0 )
77 bool potentialIllegalContinuation=
false;
96 if( potentialIllegalContinuation ) {
98 if( !isalnum( nextChar ) )
100 identifier, argNo,
CmdLine->GetArg(argNo) );
111 if( valueSeparator > 0) {
112 Args.push_back( inArgArgument );
113 if(argsExpected > 0 )
119 if ( argsExpected >
integer(argsLeft) )
122 argsExpected, argsLeft );
125 for(
integer i= 0; i < argsExpected; ++i )
149 while( paramDeclIt != decl.
Parameters.end() ) {
151 bool continueReading= param.
Read( **paramDeclIt );
155 if ( (*paramDeclIt)->IsOptional() )
167 if( !continueReading )
178 if( paramDecl->Name().Equals<
NC>(name) ) {
182 ALIB_ASSERT_ERROR( found,
"CLI",
"Requested parameter \"{}\" not defined.", name )
186 if( param->Declaration->Name().Equals<
NC>( name ) )
190 if( param->Declaration->Name().Equals<
NC>( name ) )
198 return param && param->
Args.IsNotEmpty() ? param->
Args.front()
209 if ( identifier.IsEmpty() && decl.
IsOptional() )
214 if( valueSeparator > 0 )
217 if ( identifier.IsEmpty()
228 Args.push_back( arg );
231 Args.push_back( inArgArgument );
236 if( argsExpected < 0 )
243 argsExpected,
CmdLine->ArgsLeft.size() );
246 for(
size_t i= 0; i < size_t( argsExpected ); ++i ) {
257void ERCommandDecl ::Parse() {
263void EROptionDecl ::Parse() {
282void ERExitCodeDecl ::Parse() {
284 ERSerializable::MinimumRecognitionLength = 0;
ERCommandDecl record
A copy (!) of the enum record.
ListMA< ParameterDecl * > Parameters
Command parameters.
CommandLine & CmdLine
The command line instance we belong to.
ALIB_DLL ParameterDecl * GetParameterDecl(const String &name)
int MinimumRecognitionLength()
const String & Identifier()
ALIB_DLL void addParamDecls()
int MinimumRecognitionLength()
const String & ValueSeparator()
integer QtyExpectedArgsFollowing()
const String & Identifier()
character IdentifierChar()
const String & Identifier()
int MinimumRecognitionLength()
int QtyExpectedArgsFollowing()
const String & ValueSeparator()
constexpr integer Length() const
constexpr bool IsEmpty() const
integer IndexOf(TChar needle, integer startIdx=0) const
TChar CharAt(integer idx) const
constexpr bool IsNotEmpty() const
constexpr bool IsNull() const
bool StartsWith(const TString &needle) const
bool ConsumeString(const TString< TChar > &consumable)
TSubstring & Split(integer position, TSubstring &target, integer separatorWidth=0, bool trim=false)
ALIB_DLL TSubstring< TChar > & Next(lang::Whitespaces trimming=lang::Whitespaces::Trim, TChar newDelim='\0')
TSubstring< TChar > Actual
#define ALIB_CALLER_NULLED
#define ALIB_ASSERT_ERROR(cond, domain,...)
@ IllegalOptionNameContinuation
constexpr String NULL_STRING
A nulled string of the default character type.
strings::util::TTokenizer< character > Tokenizer
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
exceptions::Exception Exception
Type alias in namespace alib.
strings::TString< character > String
Type alias in namespace alib.
characters::character character
Type alias in namespace alib.
strings::TSubstring< character > Substring
Type alias in namespace alib.
ALIB_DLL Parameter * GetParsedParameter(const String &name)
ALIB_DLL bool Read(CommandDecl &decl)
ALIB_DLL String GetParsedParameterArg(const String &name)
CommandDecl * Declaration
The underlying declaration.
ListMA< Parameter *, Recycling::Shared > ParametersMandatory
Mandatory parameters parsed.
ListMA< Parameter *, Recycling::Shared > ParametersOptional
Optional parameters parsed.
String parameters
List of parameters attached. Separated by '/'.
int associatedCLIException
The CLI module exception associated to this exit code.
integer RequiredArguments
String shortcutReplacementString
ALIB_DLL void Parse()
Implementation of EnumRecordPrototype::Parse.
String identifier
The identifier of the parameter.
bool isOptional
Denotes if this is an optional parameter.
OptionDecl * Declaration
The declaration struct.
ALIB_DLL bool Read(OptionDecl &decl, String &arg, const integer argNo)
ListMA< String, Recycling::Shared > Args
Arguments belonging to this option.
A declaration for a cli::Parameter.
ListMA< String, Recycling::Shared > Args
Arguments belonging to us.
ParameterDecl * Declaration
The underlying declaration.
ALIB_DLL bool Read(ParameterDecl &decl)
integer ConsumedArguments
CommandLine * CmdLine
The cli command line.
static ALIB_DLL void Get(String &result, bool isLastField=false)