ALib C++ Framework
by
Library Version: 2511 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
appclicamp.cpp
1//--------------------------------------------------------------------------------------------------
2// ALib C++ Framework
3// Configuration Sample
4//
5// Copyright 2025 A-Worx GmbH, Germany
6// Published under Boost Software License (a free software license, see LICENSE.txt)
7//--------------------------------------------------------------------------------------------------
8#include "alib_precompile.hpp"
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"
11#endif
12#if ALIB_C20_MODULES
13 module;
14#endif
15
16//========================================= Global Fragment ========================================
20//============================================== Module ============================================
21#if ALIB_C20_MODULES
22 module ALib.App;
23 import ALib.App.Impl;
24 import ALib.Lang;
25 import ALib.Strings;
26 import ALib.Boxing;
27 import ALib.EnumRecords;
28 import ALib.EnumRecords.Bootstrap;
29 import ALib.Variables;
30#else
31# include "ALib.App.CLI.H"
32#endif
33
34//========================================== Implementation ========================================
36
37namespace alib::app {
38
41 // Add bulk !
42 resourcePool->BootstrapBulk( ResourceCategory,
43 #define EOS ,
44
45//TODO Hier gehts weiter: Was muss sonst noch rüber ins Demo???
46
47//------------------------------------------ Single Strings ----------------------------------------
48"AppVersion", A_CHAR("V.{}."),
49//"AppInfo", A_CHAR( "@HL-"
50// "Command line tool 'date'. V. {}.{} (in fact a sample application only)\n"
51// "(c) 2023-{} AWorx GmbH. Published under MIT License (Open Source).\n"
52// "For more information, see: https://alib.dev\n"
53// "@HL-"),
54
55"USAGEFOLLOWS", A_CHAR(" Usage information follows:") ,
56
57
58//--------------------------------------------- Commands -------------------------------------------
59"Commands<", A_CHAR("Commands::"),
60"Commands" , A_CHAR(
61//enum ident minread Params
62"1," "help" ",1" ",TOPIC" ","
63"2," "version" ",3" "," ","
64"3," "info" ",4" "," ","
65"4," "setvariables" ",4" "," ) EOS
66
67
68"THlpCmdSht_help",
69"Shows general help, help on topics and tests custom expressions",
70"THlpCmdLng_help",
71"Shows general help, respectively detail help on the optionally given TOPIC(s), which "
72"can be a command or an option - or a parameter of such.\n"
73"If command 'help' is given, no further CLI commands are processed and execution is stopped "
74"with the display of the result.\n"
75"\n"
76"Besides AWax options, commands and parameter names, the following special topics are "
77"available in addition:\n"
78"\n@*>"
79"Variables@p"
80"Lists AWax configuration variables which are defaulted in software, configurable with "
81"INI-files (see option --config) and can be overridden using environment variables or "
82"CLI arguments.\n"
83"@<*" EOS
84
85"THlpCmdSht_version", "todo",
86"THlpCmdLng_version", "todo",
87"THlpCmdSht_info", "todo",
88"THlpCmdLng_info", "todo",
89"THlpCmdSht_setvariables", "todo",
90"THlpCmdLng_setvariables", "todo",
91
92
93//--------------------------------------------- Options --------------------------------------------
94"Options", A_CHAR(
95//enum ident minread identChar in-arg-separ. args to consume ShortcutTo
96"1," "help" ",4," "h," "=" ",0," ","
97"2," "version" ",7," "," "" ",0," ","
98"3," "dryrun" ",6," "d," "=" ",0," ","
99"4," "config" ",6," "c," "=" ",1," ","
100"5," "verbose" ",7," "v," "=" ",0," )EOS
101
102"Options<",A_CHAR("Options::"),
103"TOptUsg_help" ,A_CHAR("--help[[=]TOPIC]") ,
104"TOptHlp_help" ,A_CHAR("Displays usage information.") ,
105"TOptUsg_version" ,A_CHAR("--version") ,
106"TOptHlp_version" ,A_CHAR("Displays the version of this software.") ,
107"TOptUsg_dryrun" ,A_CHAR("-d|--dryrun[=][DRYRUNMODE]") ,
108"TOptHlp_dryrun" ,A_CHAR("Enables dryrun-mode for sandbox testing. No changes are performed.") ,
109"TOptUsg_config" ,A_CHAR("--config=filename1[[,filename2],filename3]...") ,
110"TOptHlp_config" ,A_CHAR("Allows to change the name (and path) of the configuration file(s)") ,
111"TOptUsg_verbose" ,A_CHAR("--verbose[=\"level\"]") ,
112"TOptHlp_verbose" ,A_CHAR("Changes verbosity to 'VERBOSE' or the optionally given preset. )") EOS
113
114//-------------------------------------------- Parameters ------------------------------------------
115"Parameters", A_CHAR(
116//enum name minIdentLen identifier in-arg-sep delim args to consume isOptional
117// (if empty -> mandatory!)
118"0," "FILENAME" ",1," "" "," "=" "," ",-1" ",0" ","
119"1," "TOPIC" ",1," "" "," "=" "," ",-1" ",1" ) EOS
120
121"Parameters<", A_CHAR("Parameters::"),
122"THlpParSht_TOPIC" , A_CHAR("Optional parameter of command (or option) 'help'."),
123"THlpParLng_TOPIC" , A_CHAR("Denotes a specific topic that the help command should be verbose about.")
124EOS
125
126//-------------------------------------------- ExitCodes -------------------------------------------
127"BIExitCodes", A_CHAR(
128//enum name assoc. cli exception
129 "0," "OK" ",-1,"
130 "10," "ErrConfigFileNotFound" ",-1,"
131 "11," "ErrConfigFileNotWritable" ",-1,"
132"127," "UnknownError" ",-1" ) EOS
133
134"BIExitCodes<", A_CHAR("ExitCodes::")
135
136, "TExit0", A_CHAR("Success (no error).")
137, "TExit10", A_CHAR("Configuration file {!Q} not found.") // todo {!Q} not yet passed with exit
138, "TExit11", A_CHAR("Configuration file {!Q} not writeable.") // todo {!Q} not yet passed with exit
139,"TExit127", A_CHAR("An unexpected (unhandled) internal error occured.")
140EOS
141
142"ExitCodes", A_CHAR(
143//enum name assoc. cli exception
144"1," "ErrNoCmdGiven" ",-1,"
145"2," "ErrUnknownCommand" ",-1,"
146"3," "ErrParsingOption" ",-1,"
147"4," "ErrParsingCommand" ",-1,"
148"5," "ErrMissingCmdParam" ",-1,"
149"6," "ErrMissingOptParam" ",-1,"
150"7," "ErrBadParamValue" ",-1") EOS
151
152"ExitCodes<", A_CHAR("ExitCodes::")
153
154,"TExit1" , A_CHAR("No command given.")
155,"TExit2" , A_CHAR("Unknown command {!Q} given.")
156,"TExit3" , A_CHAR("Unknown option {!Q} was given.")
157,"TExit4" , A_CHAR("An error occured when parsing the command {!Q}:")
158,"TExit5" , A_CHAR("Missing a mandatory parameter {!Q} of the given command {!Q}.")
159,"TExit6" , A_CHAR("Missing a mandatory parameter {!Q} of the given option {!Q}.")
160,"TExit7" , A_CHAR("Parameter {!Q} is not suitable for command or option {!Q}.")
161EOS
162
163//-------------------------------------------- Help Texts ------------------------------------------
164"HlpHdlOpts" , A_CHAR("OPTIONS:" ) EOS
165"HlpHdlCmds" , A_CHAR("COMMANDS:" ) EOS
166"HlpHdlExtCds" , A_CHAR("EXIT-CODES:" ) EOS
167"HlpHdlUsage" , A_CHAR("USAGE:" ) EOS
168"HlpHdlDscr" , A_CHAR("DESCRIPTION:" ) EOS
169"HlpHdlPDscr" , A_CHAR("PARAMETER DESCRIPTION:" ) EOS
170"HlpHdlTopic" , A_CHAR("Help on {} {!Q<>}:\n" ) EOS
171
172
173
174 // end of BootstrapBulk()
175 nullptr );
176
182
183 }
184
191} }
192
193} // namespace [alib::app]
#define A_CHAR(STR)
Definition alib.inl:1325
#define ALIB_BOXING_BOOTSTRAP_REGISTER_FAPPEND_FOR_APPENDABLE_TYPE(TAppendable)
virtual void Bootstrap() override
Initialization of the module.
BootstrapPhases GetBootstrapState()
Definition camp.inl:160
SPResourcePool resourcePool
Shared pointer to the resource pool.
Options
Built-in options used with class #"AppCli".
ExitCodes
Built-in exit-code used with class #"AppCli".
Commands
Built-in commands used with class #"AppCli".
Parameters
Built-in parameters of commands and options used with class #"AppCli".
void Bootstrap(camp::Camp &camp, const NString &name, character innerDelim=',', character outerDelim=',')
Definition camp.inl:265
app::AppCliCamp APPCLI_CAMP
The singleton instance of the camp class used by class #"AppCli".