-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
88 lines (69 loc) · 2.61 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <iostream>
#include <vector>
#include <fstream>
#include <string>
#include <queue>
#include <cmath>
#include <chrono>
#include <ctime>
#include "step.h"
#include "bruteforce.h"
#include "heuristic.h"
#include "wordlist.h"
#include "tests.h"
using namespace std;
void print_usage();
void help();
int main(int argc, char ** argv)
{
if(!argv[1])
{
print_usage();
return 0;
}
if( argc != 2 && argc != 4 && argc != 5 )
{
print_usage();
return 0;
}
string arg1(argv[1]);
if(arg1 == "-help")
{
help();
return 0;
}
if(arg1 == "-compare")
test_alghoritms(argv[2], stoi(argv[3]));
if(arg1 == "-generate")
generate_mode(argv[2], stoi(argv[3]), stoi(argv[4]));
if(arg1 == "-test_word_number")
test_word_number_mode(argv[2], stoi(argv[3]), stoi(argv[4]));
if(arg1 == "-test_word_lenght")
test_word_lenght_mode(argv[2], stoi(argv[3]), stoi(argv[4]));
return(0);
}
//Print usage of the program
void print_usage()
{
cout << "Usage: $ ./common_word [mode] [options]" << endl;
cout << "Example: $ ./common_word -generate 100 20 testFile" << endl;
cout << "For more info, type: $ ./common_word -help" << endl;
}
//Print program modes with parameters and short description
void help()
{
cout << "Usage: $ ./common_word [mode] [options]" << endl << endl;
cout << "----- Mode: Compare ------" << endl;
cout << "Usage: $ ./common_word -compare [filename] [word_lenght]" << endl;
cout << "Description: For an existing test instance (filename) program compares the results and time of bruteforce and heuristic alghoritm" << endl;
cout << "!!Please note that the word_lenght must be an integer between 1 and 20!!" << endl <<endl;
cout << "----- Mode: Generate ------" << endl;
cout << "Usage: $ ./common_word -generate [filename] [word_number] [word_lenght]" << endl;
cout << "Description: Program generates test file and uses heuristic alghoritm on it" << endl << endl;
cout << "----- Mode: Test Word Number------" << endl;
cout << "Usage: $ ./common_word -test_word_number [filename] [starting_word_number] [word_lenght]" << endl;
cout << "Description: Program generates 9 test files (word number increasing times 2 each time) and produces a table with complexity analysis" << endl << endl;
cout << "----- Mode: Test Word Lenght------" << endl;
cout << "Usage: $ ./common_word -test_word_lenght [filename] [word_number] [starting_word_lenght]" << endl;
cout << "Description: Program generates 9 test files (word lenght increasing times 2 each time) and produces a table with complexity analysis" << endl << endl;
}