ALib C++ Framework
by
Library Version: 2511 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
samplecamp.cpp
Go to the documentation of this file.
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/// \file
9#include "samplecamp.hpp"
10#if !DOXYGEN // otherwise this sample would be seen in the ALib dox
11
12// namespaces to use locally
13using namespace alib;
14using namespace alib::cli;
15
16DOX_MARKER( [DOX_EXPR_TUT_CLI_CUSTOM_CAMP_IMPL])
17void SampleCamp::Bootstrap() {
18 if( GetBootstrapState() == BootstrapPhases::PrepareResources) {
19 // Add bulk !
20 resourcePool->BootstrapBulk( ResourceCategory,
21 #define EOS ,
22
23// ################################### Single Strings ######################################
24"AppInfo", A_CHAR( "@HL-"
25 "Command line tool 'date'. V. {}.{} (in fact a sample application only)\n"
26 "(c) 2023-{} AWorx GmbH. Published under MIT License (Open Source).\n"
27 "For more information, see: https://alib.dev\n"
28 "@HL-"),
29
30// ######################################## Commands ######################################
31"Commands", A_CHAR(
32 //enum ident minread Params
33 "1," "now" ",1" "," ","
34 "2," "file" ",1" ",filename" ","
35 "99," "help" ",1" ",topic" ) EOS
36
37"Commands<", A_CHAR("datesample::Commands::"),
38
39"THlpCmdSht_now", A_CHAR("Reports the actual date/time"),
40"THlpCmdLng_now", A_CHAR("Reports the actual date/time. May be omitted, as this is the\n"
41 "default if no command is given.") EOS
42
43"THlpCmdSht_file", A_CHAR("Returns the date/time of a file. "),
44"THlpCmdLng_file", A_CHAR("Returns the last modification date/time of a file.") EOS
45
46"THlpCmdSht_help", A_CHAR("Displays usage information. "),
47"THlpCmdLng_help", A_CHAR("Displays usage information. Can also be given as an "
48 "option '--help'.") EOS
49
50
51// ######################################## Options ######################################
52"Options<", A_CHAR("datesample::Options::"),
53"Options", A_CHAR(
54//enum ident minread identChar in-arg-separ. args to consume ShortcutTo
55 "0," "format" ",1," "f," "=" ",1," ","
56"99," "help" ",1," "h," "=" ",0," ) EOS
57
58"TOptUsg_format", A_CHAR("--format[=]\"placeholders\""),
59"TOptHlp_format", A_CHAR("Sets the output format. The format specification is given with\n"
60 "documentation of ALib method CalendarDateTime::Format, found here:\n"
61 "https://alib.dev/classalib_1_1strings_1_1util_1_1CalendarDateTime.html" ) ,
62"TOptUsg_help" , A_CHAR("--help[[=]TOPIC]"),
63"TOptHlp_help" , A_CHAR("Displays usage information.")
64EOS
65
66// ######################################## Parameters ######################################
67"Parameters", A_CHAR(
68//enum name minIdentLen identifier in-arg-sep delim args to consume isOptional
69// (if empty -> mandatory!)
70"0," "FILENAME" ",1," "" "," "=" "," ",-1" ",0" ","
71"1," "TOPIC" ",1," "" "," "=" "," ",-1" ",1" ) EOS
72
73"Parameters<", A_CHAR("datesample::Parameters::"),
74"THlpParSht_FILENAME", A_CHAR("Mandatory parameter of command 'file."),
75"THlpParLng_FILENAME", A_CHAR("Denotes the file that is used for retrieving the modification date.\n"
76 "This parameter is mandatory to command file and has to be appended\n"
77 "to this command, separated by '='"),
78"THlpParSht_TOPIC" , A_CHAR("Optional parameter of command (or option) 'help'."),
79"THlpParLng_TOPIC" , A_CHAR("Denotes a specific topic that the help command should be verbose about.")
80EOS
81
82// ######################################## ExitCodes ######################################
83"ExitCodes", A_CHAR(
84//enum name assoc. cli exception
85 "0," "OK" ",-1" ","
86"100," "ErrUnknownCommand" ",-1" ","
87"101," "ErrUnknownOption" ",-1" ","
88"102," "ErrMissingFilename" ",-1" ","
89"103," "ErrUnknownHelpTopic" ",-1" ","
90"255," "ErrInternalError" ",-1" ) EOS
91
92"ExitCodes<", A_CHAR("datesample::"),
93
94 "TExit0" , A_CHAR("Success (no error).")
95,"TExit100" , A_CHAR("An unknown command was given. Valid commands are 'now' and 'file'")
96,"TExit101" , A_CHAR("An unknown option was given. The only valid option is '--format='FORMATSPEC'.")
97,"TExit102" , A_CHAR("Command 'file' given without a filename argument.")
98,"TExit103" , A_CHAR("Command or option 'help' given without an unknown subtopic.")
99,"TExit255" , A_CHAR("Unspecified internal error.")
100EOS
101
102// ################################### Help Texts ######################################
103"HlpCLIAppName", A_CHAR("date"),
104"HlpUsage" , A_CHAR("date [format=\"FORMATSPEC\" [now]|[file FILENAME]"),
105"HlpHdlOpts" , A_CHAR("OPTIONS:" ),
106"HlpHdlCmds" , A_CHAR("COMMANDS:" ),
107"HlpHdlExtCds" , A_CHAR("EXIT-CODES:" ),
108"HlpHdlUsage" , A_CHAR("USAGE:" ),
109"HlpHdlDscr" , A_CHAR( "DESCRIPTION:" ),
110"HlpHdlPDscr" , A_CHAR("PARAMETER DESCRIPTION:" ),
111"HlpHdlTopic" , A_CHAR("Help on {} {!Q<>}:\n" ),
112
113"HlpGeneral", A_CHAR(
114"\nABOUT date\n"
115"@>>"
116"This is a sample application provided with C++ library 'ALib'\n"
117"to demonstrate the use of its module \"ALib CLI\"."
118"\n@<<\n" )
119EOS
120
121 // end of BootstrapBulk()
122 nullptr );
123 }
124
125 else if( GetBootstrapState() == BootstrapPhases::PrepareConfig ) {
130 }
131}
132
133// Terminate this module. (Nothing to do.)
134void SampleCamp::Shutdown( ShutdownPhases ) {}
135DOX_MARKER( [DOX_EXPR_TUT_CLI_CUSTOM_CAMP_IMPL])
136
137DOX_MARKER( [DOX_EXPR_TUT_CLI_CUSTOM_CAMP_SINGLETON])
138// The module' singleton object
139SampleCamp SAMPLE_CAMP;
140DOX_MARKER( [DOX_EXPR_TUT_CLI_CUSTOM_CAMP_SINGLETON])
141
142#endif // !DOXYGEN
#define A_CHAR(STR)
Definition alib.inl:1325
void Bootstrap(camp::Camp &camp, const NString &name, character innerDelim=',', character outerDelim=',')
Definition camp.inl:265
ShutdownPhases
Termination levels usable with #"alib_mod_bs_camps;Bootstrapping ALib Camps".
Definition camp.inl:42