-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
61 lines (55 loc) · 1.22 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
52
53
54
55
56
57
58
59
60
61
#include <iostream>
#include <stdexcept>
#include "comics.h"
namespace
{
int usage(const char *program)
{
std::cerr << "Usage: " << program
<< " <jsondir> (-s <script writer name>|-p <penciler name>|-i <inker name>|-c <colorist name>)\n";
return 1;
}
} // namespace
int main(int argc, char *argv[])
{
if (argc != 4)
{
return usage(argv[0]);
}
try
{
std::shared_ptr db{comics::createDatabase(argv[1])};
const std::string option{argv[2]};
const std::string name{argv[3]};
if (option == "-s")
{
db->printScriptSequences(std::cout, name);
}
else if (option == "-p")
{
db->printPencilSequences(std::cout, name);
}
else if (option == "-i")
{
db->printInkSequences(std::cout, name);
}
else if (option == "-c")
{
db->printColorSequences(std::cout, name);
}
else
{
return usage(argv[0]);
}
}
catch (const std::exception &bang)
{
std::cerr << "Unexpected exception: " << bang.what() << '\n';
return 2;
}
catch (...)
{
return 3;
}
return 0;
}