cepgen is hosted by Hepforge, IPPP Durham
CepGen 1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
cepgenDescribeModules.cc
Go to the documentation of this file.
1/*
2 * CepGen: a central exclusive processes event generator
3 * Copyright (C) 2022-2024 Laurent Forthomme
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include <fstream>
20
22#include "CepGen/Generator.h"
26
27using namespace std;
28
29int main(int argc, char* argv[]) {
30 string doc_generator, output_file;
31 vector<string> addons, categories, modules_names;
32 bool quiet;
33 cepgen::ArgumentsParser(argc, argv)
34 .addOptionalArgument("documentation-generator,D", "type of documentation", &doc_generator, "text")
35 .addOptionalArgument("add-ons,a", "external runtime plugin", &addons)
36 .addOptionalArgument("output,o", "output file", &output_file, "")
37 .addOptionalArgument("categories,C", "categories to document", &categories, vector<string>{})
38 .addOptionalArgument("modules,m", "module names to document", &modules_names, vector<string>{})
39 .addOptionalArgument("quiet,q", "quiet mode", &quiet, false)
40 .parse();
41
42 if (quiet)
43 CG_LOG_LEVEL(nothing);
45 for (const auto& lib : addons) // loading of additional plugins into the runtime environment manager
46 try {
48 } catch (const cepgen::Exception& e) {
49 e.dump();
50 }
51 auto gen = cepgen::DocumentationGeneratorFactory::get().build(
52 doc_generator, cepgen::ParametersList().set("categories", categories).set("modules", modules_names));
53 const auto documentation = gen->describe();
54
55 if (output_file.empty()) {
56 if (quiet)
57 CG_LOG_LEVEL(information);
58 CG_LOG << documentation;
59 } else {
60 ofstream of(output_file);
61 of << documentation;
62 of.close();
63 CG_INFO("main") << "Documentation written in '" << output_file << "'.";
64 }
65
66 return 0;
67}
#define CG_LOG_LEVEL(type)
Definition Logger.h:83
#define CG_LOG
Definition Message.h:212
#define CG_INFO(mod)
Definition Message.h:216
A generic command line arguments parser.
ArgumentsParser & parse()
Associate command-line arguments to parameters.
ArgumentsParser & addOptionalArgument(Args &&... args)
Add a non-mandatory parameters that can be parsed.
void dump(std::ostream *os=nullptr) const noexcept override
Human-readable dump of the exception.
Definition Exception.cpp:41
bool loadLibrary(const std::string &path, bool match)
Import a shared library in RTE Launch the initialisation procedure.
void initialise(bool safe_mode)
int main()