ALib C++ Framework
by
Library Version: 2511 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
clicamp.inl
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header-file is part of module \alib_cli of the \aliblong.
4///
5/// \emoji :copyright: 2013-2025 A-Worx GmbH, Germany.
6/// Published under #"mainpage_license".
7//==================================================================================================
8ALIB_EXPORT namespace alib { namespace cli {
9
10class CommandLine;
11
12//==================================================================================================
13/// The module class for module \alib_cli_nl.
14///
15/// This is a strict singleton class. The only instance is found with the namespace variable
16/// #"alib::CLI".
17//==================================================================================================
18class CliCamp : public camp::Camp
19{
20 public:
21 /// Constructor.<br>
22 /// While this is public, it must not be invoked as this is a strict singleton type.
23 /// (See notes in #"alib_camp_camp").
24 CliCamp();
25
26 protected:
27 /// Initializes this camp.
28 virtual void Bootstrap() override;
29
30 /// Terminates this camp. (Nothing to do.)
31 /// @param phase The shutdown phase to perform.
32 virtual void Shutdown( ShutdownPhases phase ) override { (void) phase; }
33
34}; // class CliCamp
35
36//==================================================================================================
37/// Exceptions of module #"alib::cli;2".
38/// As usual with class #"exc Exception", some of the exceptions are "inner exceptions"
39/// that are caught internally and re-thrown with more information and a different exception code.
40///
41/// The in this respect "external" exceptions that have to be caught by users of the library, are:
42///
43/// - \b %NoCommandGiven,
44/// - \b %UnknownCommand,
45/// - \b %ParsingOptions and
46/// - \b %ParsingCommand.
47//==================================================================================================
48enum class Exceptions
49{
50// todo: this whole exception thing is doubtful for me. For example
51// NoCommandGiven and UnknownCommand are never thrown when using AppCli, because
52// this class detects that before they would be thrown in CommandLine::NextCommand
53//
54// Also, this whole "automatic-convert-exception-to-exitcode" thing is too complicated
55// to be really useful. Such conversion has to be made in code by the user (or AppCli) but
56// not as a resourced thing.
57// When all is done more or less, it should be decided to throw it out.
58//
59// update(251208 17:30): Ich glaube ich habe langsam verstanden warum ich das gemacht hatte.
60// ist aber doch quatsch. Ich habe einen längeren Kommentar über die App::exceptionToExitCode
61// geschrieben.
62
63
64
65 // main exceptions to be handled by the user
66 NoCommandGiven = 1, ///< Unknown command given.
67 UnknownCommand = 2, ///< Unknown command given.
68 ParsingOptions =10, ///< General option parse error. Adds option help text.
69 ParsingCommand =20, ///< General parameter parse error. Adds command help text.
70
71 // inner exceptions
72 MissingOptionValue =11, ///< Missing argument when reading option.
73 ///< (Will be generalized with ParsingOptions.)
74 IllegalOptionNameContinuation =12, ///< An option was given in long name, but continued after
75 ///< its name in an undefined way.
76 ///< (Will be generalized with ParsingOptions.)
77
78 MissingParameterValue =21, ///< Missing argument when reading parameter.
79 ///< (Will be generalized with ParameterError.)
80};
81
82//==================================================================================================
83/// Dry run modes.
84//==================================================================================================
85enum class DryRunModes
86{
87 Off , ///< No dry run
88 CLIArgs , ///< Displays the results of the command-line argument parsing.
89 CLIDeclarations, ///< Just displays the cli setup. This is more for debugging or interested users.
90 Application , ///< Dry run on application level: Given commands are invoked, nothing is
91 ///< executed, but probably log information is written. Application specific behavior.
92 ///< This is the default if no argument is given to the dry-run opton
93};
94
95} // namespace alib[::cli]
96
97/// The singleton instance of \alibcamp class #"CliCamp".
98extern ALIB_DLL cli::CliCamp CLI;
99
100} // namespace [alib]
101
#define ALIB_DLL
Definition alib.inl:573
#define ALIB_EXPORT
Definition alib.inl:562
#define ALIB_BOXING_VTABLE_DECLARE(TMapped, Identifier)
#define ALIB_RESOURCED_IN_CAMP(T, Camp, ResName)
virtual void Shutdown(ShutdownPhases phase) override
Definition clicamp.inl:32
virtual void Bootstrap() override
Initializes this camp.
Definition clicamp.cpp:62
#define ALIB_ENUMS_ASSIGN_RECORD(TEnum, TRecord)
DryRunModes
Dry run modes.
Definition clicamp.inl:86
@ CLIDeclarations
Just displays the cli setup. This is more for debugging or interested users.
Definition clicamp.inl:89
@ CLIArgs
Displays the results of the command-line argument parsing.
Definition clicamp.inl:88
@ ParsingOptions
General option parse error. Adds option help text.
Definition clicamp.inl:68
@ ParsingCommand
General parameter parse error. Adds command help text.
Definition clicamp.inl:69
@ NoCommandGiven
Unknown command given.
Definition clicamp.inl:66
@ UnknownCommand
Unknown command given.
Definition clicamp.inl:67
ShutdownPhases
Termination levels usable with #"alib_mod_bs_camps;Bootstrapping ALib Camps".
Definition camp.inl:42
cli::CliCamp CLI
The singleton instance of ALib Camp class #"CliCamp".
Definition clicamp.cpp:42