MPS-Basic
Loading...
Searching...
No Matches
main.cpp File Reference
#include "common.hpp"
#include "simulation.hpp"
#include <argparse/argparse.hpp>
#include <filesystem>
Include dependency graph for main.cpp:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 entry point of the program
 

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

entry point of the program

Parameters
argcnumber of arguments
argvarray of arguments
Returns
return code

Definition at line 19 of file main.cpp.

19 {
20 argparse::ArgumentParser program("mps");
21
22 program.add_argument("-s", "--setting")
23 .required()
24 .help("path to setting file")
25 .action([](const std::string& value) {
26 if (!fs::exists(value)) {
27 cout << "ERROR: The setting file " << value << " does not exist" << endl;
28 cerr << "ERROR: The setting file " << value << " does not exist" << endl;
29 exit(-1);
30 }
31 cout << "Setting file: " << value << endl;
32 return value;
33 });
34
35 program.add_argument("-o", "--output")
36 .required()
37 .help("path to output directory")
38 .action([](const std::string& value) {
39 if (!fs::exists(value)) {
40 cout << "ERROR: The output directory " << value << " does not exist" << endl;
41 cerr << "ERROR: The output directory " << value << " does not exist" << endl;
42 exit(-1);
43 }
44 cout << "Output directory: " << value << endl;
45 fs::create_directories(value);
46 return value;
47 });
48
49 // Although the use of exeptions is prohibited by the guidelines of this project,
50 // the following process is shown in the document of the argpase library,
51 // so we use here as an execptional calse.
52 try {
53 program.parse_args(argc, argv);
54 } catch (const std::exception& err) {
55 cout << err.what() << endl;
56 cerr << err.what() << endl;
57 cerr << program;
58 exit(-1);
59 }
60
61 // auto settingPath = fs::path(argv[1]);
62 auto settingPath = fs::path(program.get<std::string>("--setting"));
63 auto outputDirectory = fs::path(program.get<std::string>("--output"));
64 Simulation simulation(settingPath, outputDirectory);
65 simulation.run();
66
67 return 0;
68}
Here is the call graph for this function: