-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
49 lines (47 loc) · 1.04 KB
/
main.cpp
File metadata and controls
49 lines (47 loc) · 1.04 KB
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
#include "Factory/Factory.hpp"
#include "colors.hpp"
#include <iostream>
static bool checkProgramArgs(int ac)
{
try
{
if (ac == 1)
throw std::runtime_error("You must include a file");
if (ac > 2)
throw std::runtime_error("Program must have only one file or argument");
}
catch (const std::exception &e)
{
std::cout << RED "Error: " BWHITE << e.what() << RESET << std::endl;
return (false);
}
catch (...)
{
std::cout << RED "Error: Unexpected exception." BWHITE << RESET << std::endl;
return (false);
}
return (true);
}
int main(int ac, char **av)
{
if (!checkProgramArgs(ac))
return (1);
if (VERBOSE)
std::cout << GREEN "Program arguments verified and valid." RESET << std::endl;
Factory *factory = new Factory(av[1]);
try
{
factory->parseFactory();
}
catch (const std::exception &e)
{
std::cout << RED "Error: " BWHITE << e.what() << RESET << std::endl;
}
catch (...)
{
std::cout << RED "Error: Unexpected exception." BWHITE << RESET << std::endl;
}
factory->displayFactory();
delete factory;
return (0);
}