preCICE v3.1.2
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1#include <iostream>
2#include <precice/Tooling.hpp>
3#include <stdexcept>
4#include <string>
5
7{
8 std::cerr << "Usage:\n\n";
9 std::cerr << "Print XML reference : precice-tools xml\n";
10 std::cerr << "Print DTD for XML config : precice-tools dtd\n";
11 std::cerr << "Print Markdown reference : precice-tools md\n";
12 std::cerr << "Print preCICE version : precice-tools version\n";
13 std::cerr << " precice-tools --version\n";
14 std::cerr << "Check configuration file : precice-tools check FILE [ PARTICIPANT [ COMMSIZE ] ]\n";
15}
16
17int main(int argc, char **argv)
18{
19 if (argc < 2) {
20 printUsage();
21 return 1;
22 }
23
24 const std::string action(argv[1]);
25 const int args = argc - 2;
26
27 using namespace precice::tooling;
28
29 if (action == "dtd" && args == 0) {
30 printConfigReference(std::cout, ConfigReferenceType::DTD);
31 return 0;
32 }
33 if (action == "md" && args == 0) {
34 printConfigReference(std::cout, ConfigReferenceType::MD);
35 return 0;
36 }
37 if (action == "xml" && args == 0) {
38 printConfigReference(std::cout, ConfigReferenceType::XML);
39 return 0;
40 }
41 if ((action == "version" || action == "--version") && args == 0) {
43 return 0;
44 }
45 if (action == "check" && args >= 1 && args <= 3) {
46 std::string file(argv[2]);
47 std::string participant = (args > 1) ? std::string(argv[3]) : "";
48
49 int size = 1;
50 if (args == 3) {
51 try {
52 size = std::stoi(argv[4]);
53 } catch (std::invalid_argument &e) {
54 std::cerr << "ERROR: passed COMMSIZE is not a valid number\n";
55 printUsage();
56 return 1;
57 }
58 }
59 precice::tooling::checkConfiguration(file, participant, size);
60 return 0;
61 }
62
63 printUsage();
64 return 1;
65}
int main(int argc, char **argv)
Definition main.cpp:17
void printUsage()
Definition main.cpp:6
Contains the preCICE tooling API.
Definition Tooling.cpp:13
void checkConfiguration(const std::string &filename, const std::string &participant, int size)
Checks a given configuration.
Definition Tooling.cpp:32
std::string getVersionInformation()
Returns information on the version of preCICE.
Definition Tooling.cpp:70
T stoi(T... args)