-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
55 lines (44 loc) · 1.19 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
#include <filesystem>
#include <log.hpp>
#include <manager.hpp>
#include <options.hpp>
#include <processor.hpp>
#include <config.h>
int
main(int argc, char **argv) {
const auto *home = std::getenv("HOME");
auto home_config = std::string{home} + "/." + Options::CONFIG_NAME;
/* Load config */
Options::merge_file(home_config);
Options::merge_file(Options::CONFIG_NAME);
/* Parse arguments */
Options::merge_args(argc, argv);
const auto& options = Options::options();
/* Load plugins */
Plugins::load_plugins(Options::SYSTEM_PLUGINS_DIR);
Plugins::load_plugins(options.plugins_dir);
switch (options.mode) {
/* List plugins */
case Options::Mode::PRINT_PLUGINS:
Plugins::print_plugins();
break;
/* Print help */
case Options::Mode::PRINT_HELP:
Options::print_help(argv[0]);
break;
/* Print version */
case Options::Mode::PRINT_VERSION:
std::printf("version %u.%u\n", flower_VERSION_MAJOR, flower_VERSION_MINOR);
break;
/* Main process */
case Options::Mode::PROCESS:
try {
Flow::Processor().start();
} catch (const std::exception &e) {
Log::error("Error: %s\n", e.what());
return 2;
}
break;
}
return 0;
}