9#if !defined(ALIB_C20_MODULES) || ((ALIB_C20_MODULES != 0) && (ALIB_C20_MODULES != 1))
10# error "Configuration MACRO ALIB_C20_MODULES has to be given to the compiler as either 0 or 1"
27 import ALib.EnumRecords;
28 import ALib.EnumRecords.Bootstrap;
29 import ALib.Variables;
41 StateMachine::Command::MakeCustom<AppCli, &AppCli::bsCLIDefine> (
States::CLIDefine) );
64 for(
auto& exitCodeDecl :
cli.ExitCodeDecls )
65 if( exitCodeDecl.second->AssociatedCLIException() == element ) {
66 result= exitCodeDecl.first;
101 for(
auto& arg :
cli.OptionArgsIgnored )
111 if( dryOpt !=
nullptr ) {
114 dryOpt->Declaration->Identifier(),
115 dryOpt->Args.front() ,
116 dryOpt->Declaration->Identifier() );
141 if( optionConfig ==
nullptr )
144 Substring names= optionConfig->Args.front();
149 if (
files.size() <= cnt)
150 files.emplace_back();
153 && !
String(
"Default").StartsWith<CHK,lang::Case::Ignore>( name ) )
174 resource=
APPCLI_CAMP.TryResource(
"DryRunStart" );
185 option->
Args.front(),
192 cErr->Add(
cli.ExitCodeDecls.Find(exitCode).Mapped()->FormatString(), fp1, fp2,
204 cli.ReadNextCommands();
207 if(
cli.CommandsParsed.size() == 0 ) {
213 if(
cli.ArgsLeft.size() > 0 ) {
226 while ( !
cliStop && (actCmd=
cli.NextCommand()) !=
nullptr ) {
230 "Command \"{}\" recognized but not processed by the App.",
242 cOut->AddMarked( dryRunEnd );
247 if ( cmd ==
nullptr )
#define ALIB_ASSERT(cond, domain)
#define ALIB_LOCK_RECURSIVE_WITH(lock)
#define ALIB_ASSERT_ERROR(cond, domain,...)
Enum exceptionToExitCode(Exception &exception) override
void onRunStart() override
bool cliStop
Flag to stop the CLI processing loop.
virtual bool cliProcessCmd(cli::Command *cmd)
virtual void getConfigFilePathsFromCLIParam(StdVectorMA< ConfigFileDescriptor > &files)
virtual void bsReadDryRunOption()
Implements #"States::ReadDryRunOption": evaluate early flags (e.g., –dry-run).
virtual void bsCLIReadOptions()
cli::CommandLine cli
The command-line parser provided by module ALib CLI.
void getConfigFilePaths(StdVectorMA< ConfigFileDescriptor > &files) override
AppCli()
Constructs an instance and registers additional bootstrap states.
void onBsPreloadVariables() override
virtual void exitWithHelpOutput(Enum exitCode, const String &helpTopic=NULL_STRING, Box formatParam1=EMPTY_STRING, Box formatParam2=EMPTY_STRING)
virtual void bsCLIDefine()
Implements #"States::CLIDefine": define CLI options, flags and commands.
virtual void bsConfigureCLI()
Implements #"States::ConfigureCLI": finalize CLI after configuration import.
@ CLIReadOptions
Inserted behind #"CLIDefine".
@ ConfigureCLI
Inserted after #"States::ImportConfig": finalize CLI setup based on config.
@ CLIDefine
Inserted before #"States::ImportConfig": define CLI options and commands.
@ ReadDryRunOption
Inserted before #"States::SetupALox": evaluate early flags (e.g., dry-run).
void onBsSetNameVersionAndInfo() override
virtual void onBsPreloadVariables()
virtual void onBsSetNameVersionAndInfo()
@ SetupALox
Invokes the virtual method onBsSetupALox.
@ ImportConfig
Invokes the virtual method onBsImportConfig.
StateMachine machine
The state-machine singleton.
virtual void onSdOutput()
virtual Enum exceptionToExitCode(alib::Exception &exception)
virtual void getConfigFilePaths(StdVectorMA< ConfigFileDescriptor > &files)
@ ErrUnknown
An unknown exception occurred.
Paragraphs * cErr
Same as cOut, but used for stream std::err.
static bool GetDryOpt(CommandLine &cmdLine, Option &dryOpt)
static AString & DumpDeclarations(CommandLine &cmdLine, Paragraphs &text)
static bool GetHelp(CommandLine &cmdLine, const String &topics, Paragraphs &text)
const Enum & Element() const
const String & Identifier()
const String & Identifier()
const Enum & Type() const
constexpr bool IsEmpty() const
constexpr bool IsNotEmpty() const
TSubstring & Trim(const TCString< TChar > &whiteSpaces=CStringConstantsTraits< TChar >::DefaultWhitespaces())
TString< TChar > ConsumeToken(TChar separator=',', lang::Inclusion includeSeparator=lang::Inclusion::Include)
StringVectorMA DefaultCategories
StringVectorMA AlternativeArgs
Options
Built-in options used with class #"AppCli".
@ Config
Change name of config file(s).
ExitCodes
Built-in exit-code used with class #"AppCli".
@ ErrUnknownCommand
Unknown command.
@ ErrNoCmdGiven
No command given.
@ ErrBadParamValue
Bad parameter value.
Commands
Built-in commands used with class #"AppCli".
Parameters
Built-in parameters of commands and options used with class #"AppCli".
@ CLIDeclarations
Just displays the cli setup. This is more for debugging or interested users.
TMonoAllocator< lang::HeapAllocator > GLOBAL_ALLOCATOR
constexpr String NULL_STRING
A nulled string of the default character type.
constexpr CString NEW_LINE
A zero-terminated string containing the new-line character sequence.
boxing::Box Box
Type alias in namespace alib.
strings::TString< character > String
Type alias in namespace alib.
app::AppCliCamp APPCLI_CAMP
The singleton instance of the camp class used by class #"AppCli".
system::Path Path
Type alias in namespace alib.
strings::TSubstring< character > Substring
Type alias in namespace alib.
exceptions::Exception Exception
Type alias in namespace alib.
LocalString< 128 > String128
Type alias name for #"TLocalString;TLocalString<character,128>".
std::vector< T, StdMA< T > > StdVectorMA
Type alias in namespace alib.
boxing::Enum Enum
Type alias in namespace alib.
A command of a ALib CLI command-line.
CommandDecl * Declaration
The underlying declaration.
OptionDecl * Declaration
The declaration struct.
ListMA< String, Recycling::Shared > Args
Arguments belonging to this option.
integer ConsumedArguments