ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
clicamp.cpp
1// #################################################################################################
2// ALib C++ Library
3//
4// Copyright 2013-2025 A-Worx GmbH, Germany
5// Published under 'Boost Software License' (a free software license, see LICENSE.txt)
6// #################################################################################################
7#include "alib_precompile.hpp"
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"
10#endif
11#if ALIB_C20_MODULES
12 module;
13#endif
14// ====================================== Global Fragment ======================================
18// =========================================== Module ==========================================
19#if ALIB_C20_MODULES
20 module ALib.CLI;
21# if ALIB_STRINGS
22 import ALib.Strings;
23# endif
24# if ALIB_BOXING
25 import ALib.Boxing;
26# endif
27# if ALIB_CAMP
28 import ALib.Camp;
29# endif
30#else
31# include "ALib.Strings.H"
32# include "ALib.Boxing.H"
33# include "ALib.Camp.H"
34# include "ALib.CLI.H"
35#endif
37// ====================================== Implementation =======================================
39
40namespace alib {
41
43
44//==================================================================================================
45/// This is the reference documentation of sub-namespace \c cli of the \aliblink, which
46/// holds types of library module \alib_cli_nl.
47///
48/// Besides this reference documentation, further documentation and source code samples for this
49/// module is provided with \ref alib_mod_cli "ALib Module CLI - Programmer's Manual".
50//==================================================================================================
51namespace cli {
52
54: Camp( "CLI" )
55{
56 #if ALIB_DEBUG && !ALIB_DEBUG_ASSERTION_PRINTABLES
57 ALIB_ASSERT_ERROR( this == &CLI, "CLI",
58 "Instances of class Cli must not be created. Use singleton alib::CLI" )
59 #endif
60}
61
62#define EOS ,
64{
66 {
67
68#if !ALIB_CAMP_OMIT_DEFAULT_RESOURCES
69 resourcePool->BootstrapBulk( ResourceCategory,
70
71 //--------- Exceptions ------
72 "E<" , A_CHAR( "cli::" ),
73
74 // general exceptions
75 "E0", A_CHAR( "1,NoCommandGiven" ",ED1" ),
76 "E1", A_CHAR( "2,UnknownCommand" ",ED2" ),
77
78 // option parsing exceptions
79 "E2", A_CHAR( "10,ParsingOptions" ",ED10" ),
80 "E3", A_CHAR( "11,MissingOptionValue" ",ED11" ),
81 "E4", A_CHAR( "12,IllegalOptionNameContinuation" ",ED12" ),
82
83 // command parsing exceptions
84 "E5", A_CHAR( "20,ParsingCommand" ",ED20" ),
85 "E6", A_CHAR( "21,MissingParameterValue" ",ED21" ) EOS
86
87 // messages of general exceptions
88 "ED1", A_CHAR( "No command given." ),
89 "ED2", A_CHAR( "Unknown command found with CLI argument{!Q[]}={!Q}" ),
90 "ED10", A_CHAR( "Error parsing option. Usage:\n"
91 "{}" ),
92 "ED20", A_CHAR( "Error parsing command.\n"
93 "Usage: {}\n"
94 "{}" ),
95
96
97 // messages of internal exceptions
98 "ED11", A_CHAR( "Missing argument(s) of option {!Q<>} found with CLI argument{!Q[]}={!Q}.\n"
99 "Expected {}, given {}." ),
100
101 "ED12", A_CHAR( "Option identifier {!Q<>} found at start of CLI argument{!Q[]}={!Q},\n"
102 "while CLI argument string continues with non-argument identifier characters." ),
103
104 "ED21", A_CHAR( "Missing argument(s) of parameter {!Q<>} found with CLI argument{!Q[]}={!Q}.\n"
105 "Quantity expected {}, quantity given {}." ) EOS
106
107
108 //--------- DryRunModes ------
109 "DRM<", A_CHAR( "DryRunModes::" ),
110DOX_MARKER([DOX_CLI_DRYRUN_RESOURCES])
111"DRM" , A_CHAR( "0" "," "Off" "," "1" ","
112 "2" "," "CLIDeclarations" "," "4" ","
113 "1" "," "CLIArgs" "," "1" ","
114 "3" "," "Application" "," "1" ),
115DOX_MARKER([DOX_CLI_DRYRUN_RESOURCES])
116 // end of BootstrapBulk()
117 nullptr );
118#endif // !ALIB_CAMP_OMIT_DEFAULT_RESOURCES
119
120 // parse enum records
123 }
124
126 {}
128 {}
129
130}
131
132
133}} // namespace alib::cli
134
NCString ResourceCategory
Definition camp.inl:113
BootstrapPhases GetBootstrapState()
Definition camp.inl:176
Camp(const NCString &resourceCategory)
Definition camp.inl:120
SPResourcePool resourcePool
Definition camp.inl:95
virtual void Bootstrap() override
Initializes this camp.
Definition clicamp.cpp:63
#define ALIB_BOXING_VTABLE_DEFINE(TMapped, Identifier)
#define A_CHAR(STR)
#define ALIB_ASSERT_ERROR(cond, domain,...)
Definition alib.inl:1049
void Bootstrap(camp::Camp &camp, const NString &name, character innerDelim=',', character outerDelim=',')
Definition camp.inl:329
@ Final
The final initialization phase. Here, camps are initializing their custom setup.
Definition camp.inl:35
cli::CliCamp CLI
The singleton instance of ALib Camp class CliCamp.
Definition clicamp.cpp:42