ALib C++ Library
Library Version: 2510 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 \ref mainpage_license "Boost Software 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/// \ref alib::CLI.
17//==================================================================================================
18class CliCamp : public camp::Camp
19{
20 public:
21 //==========================================================================================
22 /// Constructor.<br>
23 /// While this is public, it must not be invoked as this is a strict singleton type.
24 /// (See notes in \ref alib_camp_camp).
25 //==========================================================================================
26 CliCamp();
27
28 protected:
29 //==========================================================================================
30 /// Initializes this camp.
31 //==========================================================================================
32 virtual void Bootstrap() override;
33
34 //==========================================================================================
35 /// Terminates this camp. (Nothing to do.)
36 /// @param phase The shutdown phase to perform.
37 //==========================================================================================
38 virtual void Shutdown( ShutdownPhases phase ) override { (void) phase; }
39
40}; // class CliCamp
41
42//==================================================================================================
43/// Exceptions of module #alib::cli.
44/// As usual with class \alib{exceptions;Exception}, some of the exceptions are "inner exceptions" that
45/// are caught internally and re-thrown with more information and a different exception code.
46///
47/// The in this respect "external" exceptions that have to be caught by users of the library, are:
48///
49/// - \b %NoCommandGiven,
50/// - \b %UnknownCommand,
51/// - \b %ParsingOptions and
52/// - \b %ParsingCommand.
53//==================================================================================================
54enum class Exceptions
55{
56 // main exceptions to be handled by the user
57 NoCommandGiven = 1, ///< Unknown command given.
58 UnknownCommand = 2, ///< Unknown command given.
59 ParsingOptions =10, ///< General option parse error. Adds option help text.
60 ParsingCommand =20, ///< General parameter parse error. Adds command help text.
61
62 // inner exceptions
63 MissingOptionValue =11, ///< Missing argument when reading option.
64 ///< (Will be generalized with ParsingOptions.)
65 IllegalOptionNameContinuation =12, ///< An option was given in long name, but continued after
66 ///< its name in an undefined way.
67 ///< (Will be generalized with ParsingOptions.)
68
69 MissingParameterValue =21, ///< Missing argument when reading parameter.
70 ///< (Will be generalized with ParameterError.)
71};
72
73//==================================================================================================
74/// Dry run modes.
75//==================================================================================================
76enum class DryRunModes
77{
78 Off , ///< No dry run
79 CLIArgs , ///< Displays the results of the command line argument parsing.
80 CLIDeclarations, ///< Just displays the cli setup. This is more for debugging or interested users.
81 Application , ///< Dry run on application level: Given commands are invoked, nothing is
82 ///< executed, but probably log information is written. Application specific behavior.
83 ///< This is the default if no argument is given to the dry-run opton
84};
85
86
87} // namespace alib[::cli]
88
89/// The singleton instance of \alibcamp class \alib{cli;CliCamp}.
90extern ALIB_DLL cli::CliCamp CLI;
91
92} // namespace [alib]
93
virtual void Shutdown(ShutdownPhases phase) override
Definition clicamp.inl:38
virtual void Bootstrap() override
Initializes this camp.
Definition clicamp.cpp:63
#define ALIB_DLL
Definition alib.inl:496
#define ALIB_ENUMS_ASSIGN_RECORD(TEnum, TRecord)
#define ALIB_BOXING_VTABLE_DECLARE(TMapped, Identifier)
#define ALIB_EXPORT
Definition alib.inl:488
#define ALIB_RESOURCED_IN_MODULE(T, Camp, ResName)
DryRunModes
Dry run modes.
Definition clicamp.inl:77
@ CLIDeclarations
Just displays the cli setup. This is more for debugging or interested users.
Definition clicamp.inl:80
@ CLIArgs
Displays the results of the command line argument parsing.
Definition clicamp.inl:79
@ ParsingOptions
General option parse error. Adds option help text.
Definition clicamp.inl:59
@ ParsingCommand
General parameter parse error. Adds command help text.
Definition clicamp.inl:60
@ NoCommandGiven
Unknown command given.
Definition clicamp.inl:57
@ UnknownCommand
Unknown command given.
Definition clicamp.inl:58
ShutdownPhases
Termination levels usable with Bootstrapping ALib Camps.
Definition camp.inl:42
cli::CliCamp CLI
The singleton instance of ALib Camp class CliCamp.
Definition clicamp.cpp:42