-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
51 lines (45 loc) · 2.04 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <iostream>
#include <cstring>
#include "lib/basic/basic_functions.hpp"
#include "lib/parser/arguments_parser.hpp"
#include "lib/sand_pile/sand_pile.hpp"
int main(int32_t argc, char** argv) {
if (argc == 2 && (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0)) {
PrintHelp();
return 0;
}
constexpr size_t kArgumentCount = 6;
ArgumentInformation* arguments = new ArgumentInformation[kArgumentCount];
arguments[0] = {"-i", "--input=", "Path to input file",
ArgumentType::kCompositeArgument, true,
&IsValidFilename, &IsRegularFile};
arguments[1] = {"-o", "--output=", "Path to output directory",
ArgumentType::kCompositeArgument, true,
&IsValidFilename, &IsDirectory};
arguments[2] = {"-m", "--max-iter=", "Maximum number of iterations",
ArgumentType::kLongArgument, false,
&IsValidFilename, &IsRegularFile};
arguments[3] = {"-f", "--freq=", "Frequency of output",
ArgumentType::kLongArgument, false,
&IsValidFilename, &IsRegularFile};
arguments[4] = {"-w", "--write-tsv", "Write output in TSV format",
ArgumentType::kBoolArgument, false,
&IsValidFilename, &IsRegularFile};
arguments[5] = {"-h", "--help", "Provide help",
ArgumentType::kBoolArgument, false,
&IsValidFilename, &IsRegularFile};
ArgumentsParser arguments_parser(arguments, kArgumentCount);
int8_t exit_code = arguments_parser.ParseArguments(argv, argc);
if (exit_code == 0 && !arguments_parser.GetBoolValue(5)) {
SandPile sand_pile = SandPile();
sand_pile.BeginCollapsing(arguments_parser.GetCompositeValue(0),
arguments_parser.GetCompositeValue(1),
arguments_parser.GetLongValue(2),
arguments_parser.GetLongValue(3),
arguments_parser.GetBoolValue(4));
} else {
PrintHelp();
}
delete[] arguments;
return exit_code;
}