SNode.C
Loading...
Searching...
No Matches
Formatter.h
Go to the documentation of this file.
1/*
2 * SNode.C - a slim toolkit for network communication
3 * Copyright (C) Volker Christian <me@vchrist.at>
4 * 2020, 2021, 2022, 2023, 2024, 2025
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published
8 * by the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef UTILS_FORMATER_H
21#define UTILS_FORMATER_H
22
23#ifndef DOXYGEN_SHOULD_SKIP_THIS
24
25#ifdef __GNUC__
26#pragma GCC diagnostic push
27#pragma GCC diagnostic ignored "-Wfloat-equal"
28#ifdef __has_warning
29#if __has_warning("-Wweak-vtables")
30#pragma GCC diagnostic ignored "-Wweak-vtables"
31#endif
32#if __has_warning("-Wcovered-switch-default")
33#pragma GCC diagnostic ignored "-Wcovered-switch-default"
34#endif
35#endif
36#endif
37#include "utils/CLI11.hpp"
38#ifdef __GNUC__
39#pragma GCC diagnostic pop
40#endif
41
42#include <string>
43
44#endif // DOXYGEN_SHOULD_SKIP_THIS
45
46namespace CLI {
47
48 class ConfigFormatter : public ConfigBase {
49 public:
50 ~ConfigFormatter() override;
51
52 private:
53 std::string to_config(const App* app, bool default_also, bool write_description, std::string prefix) const override;
54 };
55
56 class HelpFormatter : public CLI::Formatter {
57 public:
58 ~HelpFormatter() override;
59
60 private:
61 std::string make_group(std::string group, bool is_positional, std::vector<const Option*> opts) const override;
62 std::string make_description(const App* app) const override;
63 std::string make_usage(const App* app, std::string name) const override;
64 std::string make_subcommands(const App* app, AppFormatMode mode) const override;
65 std::string make_subcommand(const App* sub) const override;
66 std::string make_expanded(const App* sub) const override;
67 std::string make_option_opts(const Option* opt) const override;
68 };
69
70} // namespace CLI
71
72#endif // UTILS_FORMATER_H
#define XSTR(s)
CLI::App * getApp() const
CallForCommandline(CLI::App *app, const std::string &description, Mode mode)
~CallForCommandline() override
CLI::App * getApp() const
~CallForShowConfig() override
CallForShowConfig(CLI::App *app)
std::string getConfigFile() const
~CallForWriteConfig() override
CallForWriteConfig(const std::string &configFile)
~ConfigFormatter() override
Definition Formatter.cpp:34
std::string to_config(const App *app, bool default_also, bool write_description, std::string prefix) const override
Definition Formatter.cpp:38
std::string make_option_opts(const Option *opt) const override
std::string make_subcommand(const App *sub) const override
~HelpFormatter() override
std::string make_description(const App *app) const override
std::string make_usage(const App *app, std::string name) const override
std::string make_subcommands(const App *app, AppFormatMode mode) const override
std::string make_expanded(const App *sub) const override
std::string make_group(std::string group, bool is_positional, std::vector< const Option * > opts) const override
static void init()
Definition Logger.cpp:32
static void setQuiet(bool quiet=true)
Definition Logger.cpp:114
static bool parse1()
Definition Config.cpp:373
static char ** argv
Definition Config.h:107
static CLI::Option * logLevelOpt
Definition Config.h:120
static std::map< std::string, CLI::Option * > applicationOptions
Definition Config.h:125
static int getVerboseLevel()
Definition Config.cpp:947
static bool parse2()
Definition Config.cpp:532
static std::string configDirectory
Definition Config.h:111
static std::shared_ptr< CLI::App > app
Definition Config.h:103
static CLI::Option * groupNameOpt
Definition Config.h:118
static CLI::Option * verboseLevelOpt
Definition Config.h:121
static CLI::Option * quietOpt
Definition Config.h:122
static bool init(int argc, char *argv[])
Definition Config.cpp:106
static int argc
Definition Config.h:106
static std::string pidDirectory
Definition Config.h:113
static std::shared_ptr< CLI::Formatter > sectionFormatter
Definition Config.h:104
static std::map< std::string, std::string > aliases
Definition Config.h:124
static void required(CLI::App *instance, bool reqired=true)
Definition Config.cpp:804
static CLI::Option * logFileOpt
Definition Config.h:116
static CLI::Option * enforceLogFileOpt
Definition Config.h:119
static bool bootstrap()
Definition Config.cpp:343
static int getLogLevel()
Definition Config.cpp:943
static std::string applicationName
Definition Config.h:109
static std::string logDirectory
Definition Config.h:112
static void terminate()
Definition Config.cpp:614
static CLI::Option * userNameOpt
Definition Config.h:117
static CLI::Option * daemonizeOpt
Definition Config.h:115
#define STR(a)
Definition clients.h:26
Definition Config.h:37
static const std::shared_ptr< CLI::App > makeApp()
Definition Config.cpp:71
static std::string createCommandLineTemplate(CLI::App *app, CLI::CallForCommandline::Mode mode)
Definition Config.cpp:512
static const std::shared_ptr< CLI::HelpFormatter > makeSectionFormatter()
Definition Config.cpp:633
static void createCommandLineTemplate(std::stringstream &out, CLI::App *app, CLI::CallForCommandline::Mode mode)
Definition Config.cpp:497
static void createCommandLineOptions(std::stringstream &out, CLI::App *app, CLI::CallForCommandline::Mode mode)
Definition Config.cpp:409
static std::string createCommandLineOptions(CLI::App *app, CLI::CallForCommandline::Mode mode)
Definition Config.cpp:467
static std::string createCommandLineSubcommands(CLI::App *app, CLI::CallForCommandline::Mode mode)
Definition Config.cpp:482