ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
clicamp.hpp
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-2024 A-Worx GmbH, Germany.
6/// Published under \ref mainpage_license "Boost Software License".
7//==================================================================================================
8#ifndef HPP_ALIB_CLI_CAMP
9#define HPP_ALIB_CLI_CAMP 1
10#pragma once
13
15
16namespace alib { namespace cli {
17
18class CommandLine;
19
20//==================================================================================================
21/// The module class for module \alib_cli_nl.
22///
23/// This is a strict singleton class. The only instance is found with namespace variable
24/// \ref alib::CLI.
25//==================================================================================================
26class CliCamp : public lang::Camp
27{
28 public:
29 //==========================================================================================
30 /// Constructor.<br>
31 /// While this is public, it must not be invoked as this is a strict singleton type.
32 /// (See notes in \ref alib_manual_camp_modules_campmodule).
33 //==========================================================================================
34 CliCamp();
35
36 protected:
37 //==========================================================================================
38 /// Initializes this camp.
39 ///
40 /// @param phase The initialization phase to perform.
41 //==========================================================================================
42 virtual void bootstrap( BootstrapPhases phase ) override;
43
44 //==========================================================================================
45 /// Terminates this camp. (Nothing to do.)
46 /// @param phase The shutdown phase to perform.
47 //==========================================================================================
48 virtual void shutdown( ShutdownPhases phase ) override { (void) phase; }
49
50}; // class CliCamp
51
52//==================================================================================================
53/// Exceptions of module #alib::cli.
54/// As usual with class \alib{lang;Exception}, some of the exceptions are "inner exceptions" that
55/// are caught internally and re-thrown with more information and a different exception code.
56///
57/// The in this respect "external" exceptions that have to be caught by users of the library, are:
58///
59/// - \b %NoCommandGiven,
60/// - \b %UnknownCommand,
61/// - \b %ParsingOptions and
62/// - \b %ParsingCommand.
63//==================================================================================================
64enum class Exceptions
65{
66 // main exceptions to be handled by the user
67 NoCommandGiven = 1, ///< Unknown command given.
68 UnknownCommand = 2, ///< Unknown command given.
69 ParsingOptions =10, ///< General option parse error. Adds option help text.
70 ParsingCommand =20, ///< General parameter parse error. Adds command help text.
71
72 // inner exceptions
73 MissingOptionValue =11, ///< Missing argument when reading option.
74 ///< (Will be generalized with ParsingOptions.)
75 IllegalOptionNameContinuation =12, ///< An option was given in long name, but continued after
76 ///< its name in an undefined way.
77 ///< (Will be generalized with ParsingOptions.)
78
79 MissingParameterValue =21, ///< Missing argument when reading parameter.
80 ///< (Will be generalized with ParameterError.)
81
82 END_OF_ENUM
83};
84
85//==================================================================================================
86/// Dry run modes.
87//==================================================================================================
88enum class DryRunModes
89{
90 Off , ///< No dry run
91 CLIArgs , ///< Displays the results of the command line argument parsing.
92 CLIDeclarations, ///< Just displays the cli setup. This is more for debugging or interested users.
93 Application , ///< Dry run on application level: Given commands are invoked, nothing is
94 ///< executed, but probably log information is written. Application specific behavior.
95 ///< This is the default if no argument is given to the dry-run opton
96};
97
98
99} // namespace alib[::cli]
100
101/// The singleton instance of \alibcamp class \alib{cli;CliCamp}.
102extern ALIB_API cli::CliCamp CLI;
103
104} // namespace [alib]
105
110
111#endif // HPP_ALIB_CLI_CAMP
112
virtual void bootstrap(BootstrapPhases phase) override
Definition clicamp.cpp:41
virtual void shutdown(ShutdownPhases phase) override
Definition clicamp.hpp:48
#define ALIB_ASSERT_MODULE(modulename)
Definition alib.hpp:223
#define ALIB_ENUMS_ASSIGN_RECORD(TEnum, TRecord)
Definition records.hpp:712
#define ALIB_API
Definition alib.hpp:639
#define ALIB_BOXING_VTABLE_DECLARE(TMapped, Identifier)
Definition vtable.inl:460
#define ALIB_RESOURCED_IN_MODULE(T, Camp, ResName)
DryRunModes
Dry run modes.
Definition clicamp.hpp:89
@ CLIDeclarations
Just displays the cli setup. This is more for debugging or interested users.
@ CLIArgs
Displays the results of the command line argument parsing.
@ ParsingOptions
General option parse error. Adds option help text.
@ ParsingCommand
General parameter parse error. Adds command help text.
@ NoCommandGiven
Unknown command given.
@ UnknownCommand
Unknown command given.
Definition alib.cpp:69
ShutdownPhases
Termination levels usable with Bootstrapping ALib Camps.
Definition alib.hpp:1418
cli::CommandLine CommandLine
Type alias in namespace alib.
BootstrapPhases
Initialization levels usable with Bootstrapping ALib Camps.
Definition alib.hpp:1393
cli::CliCamp CLI
The singleton instance of ALib Camp class CliCamp.
Definition clicamp.cpp:22