ALib C++ Library
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 \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 /// Constructor.<br>
22 /// While this is public, it must not be invoked as this is a strict singleton type.
23 /// (See notes in \ref 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.
38/// As usual with class \alib{exceptions;Exception}, some of the exceptions are "inner exceptions" that
39/// 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 // main exceptions to be handled by the user
51 NoCommandGiven = 1, ///< Unknown command given.
52 UnknownCommand = 2, ///< Unknown command given.
53 ParsingOptions =10, ///< General option parse error. Adds option help text.
54 ParsingCommand =20, ///< General parameter parse error. Adds command help text.
55
56 // inner exceptions
57 MissingOptionValue =11, ///< Missing argument when reading option.
58 ///< (Will be generalized with ParsingOptions.)
59 IllegalOptionNameContinuation =12, ///< An option was given in long name, but continued after
60 ///< its name in an undefined way.
61 ///< (Will be generalized with ParsingOptions.)
62
63 MissingParameterValue =21, ///< Missing argument when reading parameter.
64 ///< (Will be generalized with ParameterError.)
65};
66
67//==================================================================================================
68/// Dry run modes.
69//==================================================================================================
70enum class DryRunModes
71{
72 Off , ///< No dry run
73 CLIArgs , ///< Displays the results of the command line argument parsing.
74 CLIDeclarations, ///< Just displays the cli setup. This is more for debugging or interested users.
75 Application , ///< Dry run on application level: Given commands are invoked, nothing is
76 ///< executed, but probably log information is written. Application specific behavior.
77 ///< This is the default if no argument is given to the dry-run opton
78};
79
80
81} // namespace alib[::cli]
82
83/// The singleton instance of \alibcamp class \alib{cli;CliCamp}.
84extern ALIB_DLL cli::CliCamp CLI;
85
86} // namespace [alib]
87
virtual void Shutdown(ShutdownPhases phase) override
Definition clicamp.inl:32
virtual void Bootstrap() override
Initializes this camp.
Definition clicamp.cpp:62
#define ALIB_DLL
Definition alib.inl:503
#define ALIB_ENUMS_ASSIGN_RECORD(TEnum, TRecord)
#define ALIB_BOXING_VTABLE_DECLARE(TMapped, Identifier)
#define ALIB_EXPORT
Definition alib.inl:497
#define ALIB_RESOURCED_IN_MODULE(T, Camp, ResName)
DryRunModes
Dry run modes.
Definition clicamp.inl:71
@ CLIDeclarations
Just displays the cli setup. This is more for debugging or interested users.
Definition clicamp.inl:74
@ CLIArgs
Displays the results of the command line argument parsing.
Definition clicamp.inl:73
@ ParsingOptions
General option parse error. Adds option help text.
Definition clicamp.inl:53
@ ParsingCommand
General parameter parse error. Adds command help text.
Definition clicamp.inl:54
@ NoCommandGiven
Unknown command given.
Definition clicamp.inl:51
@ UnknownCommand
Unknown command given.
Definition clicamp.inl:52
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