/** * @file main.cpp * The main executable * * @author Tobias Schmidl * @copyright Copyright © 2022, Tobias Schmidl * SPDX-License-Identifier: MIT */ #include "collector.hpp" #include "monitor.hpp" #include "version.hpp" #include #include #include using namespace collector::monitor; using namespace collector::collector; using namespace boost::program_options; int main(int argc, const char* argv[]) { std::cerr << argv[0] << " Version v" << VERSION << "\n"; options_description description{ "Options" }; description.add_options()("help,h", "Help screen")( "input_dir,i", value()->required(), "Input Directory")( "output_file,o", value()->required(), "Output Tarball"); variables_map vm; try { store(parse_command_line(argc, argv, description), vm); notify(vm); } catch (std::exception& err) { std::cerr << "Error: " << err.what() << "\n"; std::cerr << description << std::endl; return 1; } std::filesystem::path input_dir, output_file; if (vm.count("help")) { std::cerr << description << std::endl; return 1; } if (vm.count("input_dir")) { input_dir = vm["input_dir"].as(); if (!std::filesystem::is_directory(input_dir)) { std::cerr << input_dir << " is not a valid directory." << std::endl; return 1; } else std::cerr << "input dir: " << input_dir << "\n"; } if (vm.count("output_file")) { output_file = vm["output_file"].as(); std::cout << "output file: " << output_file << "\n"; } boost::asio::io_service service; Collector collector(service, input_dir, output_file); return (collector() && std::filesystem::is_regular_file(output_file)) ? 0 : 2; }