ALib C++ Framework
by
Library Version: 2511 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
sample.hpp
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#ifndef HPP_ALIB_SAMPLES_APPCLI
9#define HPP_ALIB_SAMPLES_APPCLI
10#pragma once
11#include "ALib.Lang.H"
12#if !DOXYGEN // otherwise this sample would be seen in the ALib dox
13
14#include "ALib.App.CLI.H" // Module ALib App with CLI support
15
16// Our custom app
17DOX_MARKER( [DOX_APPCLI_TUT_HEADER])
18class Sample : public alib::app::AppCli {
19
20 enum class DateCommands {
21 Now = 1, ///< Returns the current date.
22 File = 2, ///< returns the modification date of a file or directory.
23 };
24
25 enum class DateOptions {
26 Format = 0, ///< Overwrite the default format string.
27 };
28
29 enum class DateParameters {
30 Filename = 0, ///< Used with command \e file to denote the file.
31 };
32
33 enum class DateExitCodes {
34 ErrMissingFilename = 101, ///< Command "file" given without a filename.
35 ErrFileNotFound = 102, ///< File given with command "file" not found.
36 ErrPermissionDenied = 103, ///< File given with command "file" not found.
37 };
38
39 alib::String64 format= "yyyy-MM-dd HH:mm:ss";
40
41 void bsCLIDefine() override;
42 void onBsPrepareConfig() override;
43 bool cliProcessCmd(alib::cli::Command* cmd ) override;
44};
45DOX_MARKER( [DOX_APPCLI_TUT_HEADER])
46
47// assigning ALib enum records
48ALIB_CAMP_ENUM( Sample::DateCommands , alib::cli::ERCommandDecl , alib::APPCLI_CAMP, "DateC" )
49ALIB_CAMP_ENUM( Sample::DateOptions , alib::cli::EROptionDecl , alib::APPCLI_CAMP, "DateO" )
50ALIB_CAMP_ENUM( Sample::DateParameters , alib::cli::ERParameterDecl, alib::APPCLI_CAMP, "DateP" )
51ALIB_CAMP_ENUM( Sample::DateExitCodes , alib::cli::ERExitCodeDecl , alib::APPCLI_CAMP, "DateE" )
52
53#endif // !DOXYGEN
54#endif // HPP_ALIB_SAMPLES_APPCLI
#define ALIB_CAMP_ENUM(T, TRecord, Camp, ResName)
virtual bool cliProcessCmd(cli::Command *cmd)
Definition appcli.cpp:246
virtual void bsCLIDefine()
Implements #"States::CLIDefine": define CLI options, flags and commands.
Definition appcli.cpp:87
virtual void onBsPrepareConfig()
Definition app.cpp:333
@ Filename
Denotes the actual source file as the scope.
files::File File
Type alias in namespace alib.
Definition ftree.inl:1055
LocalString< 64 > String64
Type alias name for #"TLocalString;TLocalString<character,64>".
app::AppCliCamp APPCLI_CAMP
The singleton instance of the camp class used by class #"AppCli".
#"alib_enums_records;ALib Enum Record" type used by class #"CommandDecl".