-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
27 lines (26 loc) 路 707 Bytes
/
Copy pathmain.cpp
File metadata and controls
27 lines (26 loc) 路 707 Bytes
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
#include <iostream>
#include "equation.h"
#include "help.h"
#include "cli.h"
// main function
int main(int argc, char** argv) {
// invalid arguments count
if(argc >= 3) {
std::cout << "Invalid arguments count.\n";
std::cout << "Type console-calc --help to learn how to use console-calc.";
}
// help message (-h)
else if(argc == 2 && (std::string(argv[1]) == "--help" || std::string(argv[1]) == "-h")) {
help();
}
// cli mode (no arguments)
else if(argc == 1) {
cli();
}
// calculate equation
else if(argc == 2) {
Equation eq(argv[1]);
std::cout << eq.getEquation() << " = " << eq.evaluate();
}
return 0;
}