-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
84 lines (70 loc) · 2.29 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
82
83
84
#include <cstdlib>
#include <iostream>
#include <thread>
#include <vector>
#include <string>
#include "ght/settings.h"
#include "cleaner/cleaner.h"
#include "cleaner/alllang.h"
#include "downloader/downloader.h"
#include "include/settings.h"
#include "sccsorter/sccsorter.h"
#include "latest/latest.h"
unsigned FolderHierarchy::FilesPerFolder = 1000;
void Clean(std::vector<std::string> const & args) {
Cleaner::ParseCommandLine(args);
Cleaner::LoadPreviousRun();
Cleaner::Spawn(1);
ProgressReporter::Start(Cleaner::GetReporterFeeder());
Cleaner::Run();
Cleaner::FeedFrom(Cleaner::InputFiles);
Cleaner::Wait();
Cleaner::Finalize();
}
void Download(std::vector<std::string> const & args) {
Downloader::ParseCommandLine(args);
Downloader::Initialize();
Downloader::LoadPreviousRun();
Downloader::OpenOutputFiles();
Downloader::Spawn(Downloader::NumThreads);
ProgressReporter::Start(Downloader::GetReporterFeeder());
Downloader::Run();
Downloader::FeedFrom(Downloader::InputFile);
Downloader::Wait();
Downloader::Finalize();
}
void Latest(std::vector<std::string> const & args) {
Latest::ParseCommandLine(args);
Latest::GetLatestSnapshot();
}
void CleanAllLang(std::vector<std::string> const & args) {
CleanerAllLang::ParseCommandLine(args);
CleanerAllLang::Spawn(1);
ProgressReporter::Start(CleanerAllLang::GetReporterFeeder());
CleanerAllLang::Run();
CleanerAllLang::FeedFrom(Cleaner::InputFiles);
CleanerAllLang::Wait();
}
int main(int argc, char * argv[]) {
try {
std::vector<std::string> args = Settings::ReadCommandLine(argc, argv);
if (argc < 2)
throw std::invalid_argument("Not enough arguments");
std::string command = args[1];
if (command == "cleaner")
Clean(args);
else if (command == "cleanerAllLang")
CleanAllLang(args);
else if (command == "downloader")
Download(args);
else if (command == "latest")
Latest(args);
else
throw std::invalid_argument(STR("Invalid command " << command));
std::cout << "DONE" << std::endl;
return EXIT_SUCCESS;
} catch (std::exception const & e) {
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
}
}