cepgen is hosted by Hepforge, IPPP Durham
CepGen 1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
cepgenCmdTester.cc
Go to the documentation of this file.
1/*
2 * CepGen: a central exclusive processes event generator
3 * Copyright (C) 2022-2023 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
22#include "CepGen/Utils/String.h"
23#include "CepGen/Version.h"
24
25using namespace std;
26
27int main(int argc, char* argv[]) {
28 string commands;
29 bool reserialise;
30 cepgen::ArgumentsParser(argc, argv)
31 .addOptionalArgument("cmd,c", "list of arguments to be parsed", &commands, "")
32 .addOptionalArgument("serial,s", "re-serialise the parsed arguments", &reserialise, false)
33 .parse();
34
35 auto plist = cepgen::ParametersList().feed(commands);
36 CG_LOG << "CepGen v" << cepgen::version::tag << " command line arguments parser parsed the following arguments:\n"
38
39 if (reserialise) {
40 const auto serialised = plist.serialise();
41 const auto col = serialised == commands ? cepgen::utils::Colour::green : cepgen::utils::Colour::yellow;
42 CG_LOG << "Re-serialised arguments: " << cepgen::utils::colourise(serialised, col, cepgen::utils::Modifier::italic)
43 << ".";
44 }
45
46 return 0;
47}
#define CG_LOG
Definition Message.h:212
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.
A description object for parameters collection.
ParametersList & feed(const std::string &)
Feed a control string to the list of parameters.
std::string colourise(const std::string &str, const Colour &col, const Modifier &mod)
Colourise a string for TTY-type output streams.
Definition String.cpp:70
int main()
static const std::string tag
CepGen version.
Definition Version.h:28