preCICE v3.3.0
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1#include <iostream>
3#include <precice/Tooling.hpp>
4#include <stdexcept>
5#include <string>
6
8{
9 std::cerr << "Usage:\n\n";
10 std::cerr << "Print XML reference : precice-tools xml\n";
11 std::cerr << "Print DTD for XML config : precice-tools dtd\n";
12 std::cerr << "Print Markdown reference : precice-tools md\n";
13 std::cerr << "Print preCICE version : precice-tools version\n";
14 std::cerr << " precice-tools --version\n";
15 std::cerr << "Check configuration file : precice-tools check FILE [ PARTICIPANT [ COMMSIZE ] ]\n";
16}
17
18int main(int argc, char **argv)
19{
20
21 std::cout << "WARNING: precice-tools is deprecated and will be removed in preCICE version 4.\n"
22 "Please use precice-version , precice-config-validate or precice-config-doc instead.\n";
23
24 if (argc < 2) {
25 printUsage();
26 return 1;
27 }
28
29 const std::string action(argv[1]);
30 const int args = argc - 2;
31
32 using namespace precice::tooling;
33
34 if (action == "dtd" && args == 0) {
36 return 0;
37 }
38 if (action == "md" && args == 0) {
40 return 0;
41 }
42 if (action == "xml" && args == 0) {
44 return 0;
45 }
46 if ((action == "version" || action == "--version") && args == 0) {
48 return 0;
49 }
50 if (action == "check" && args >= 1 && args <= 3) {
51 std::string file(argv[2]);
52 std::string participant = (args > 1) ? std::string(argv[3]) : "";
53
54 int size = 1;
55 if (args == 3) {
56 try {
57 size = std::stoi(argv[4]);
58 } catch (std::invalid_argument &e) {
59 std::cerr << "ERROR: passed COMMSIZE is not a valid number\n";
60 printUsage();
61 return 1;
62 }
63 }
64 try {
65 precice::tooling::checkConfiguration(file, participant, size);
66 } catch (const ::precice::Error &) {
67 return 2;
68 }
69 return 0;
70 }
71
72 printUsage();
73 return 1;
74}
int main(int argc, char **argv)
Definition main.cpp:18
void printUsage()
Definition main.cpp:7
contains actions to modify exchanged data.
Definition Action.hpp:6
Contains the preCICE tooling API.
Definition Tooling.cpp:13
void printConfigReference(std::ostream &out, ConfigReferenceType reftype)
Generates a configuration reference.
Definition Tooling.cpp:15
void checkConfiguration(const std::string &filename, const std::string &participant, int size)
Checks a given configuration.
Definition Tooling.cpp:32
@ XML
XML with inlined help.
Definition Tooling.hpp:25
@ MD
Markdown version used for the website.
Definition Tooling.hpp:29
std::string getVersionInformation()
Returns information on the version of preCICE.
Definition Tooling.cpp:70
T stoi(T... args)