add cli options

This commit is contained in:
Gabriel Ionita 2025-10-24 11:05:17 +01:00
parent 452d1ce082
commit c58de07577
Signed by: gabi
SSH Key Fingerprint: SHA256:LrMyvxum00K+HwzsYQc+lsxzqdX49JqIdJLc62SJqJY

View File

@ -1,5 +1,34 @@
#include <filesystem>
#include <iostream> #include <iostream>
#include <string>
#include <unistd.h>
#include <cxxopts.hpp>
#include <vector>
int main() { int main(int argc, char** argv) {
std::cout << "hello" << std::endl; cxxopts::Options options("gwatch", "A command-line variable watcher");
options.add_options()
("var", "Symbol to watch", cxxopts::value<std::string>())
("exec", "Executable to run", cxxopts::value<std::filesystem::path>())
("h,help", "Print usage");
// TODO: Figure out a way to receive arguments for the executable being ran
// ("--", "Arguents to provide to the executable", cxxopts::value<std::vector<std::string>>()->default_value({}));
auto result = options.parse(argc, argv);
if (result.count("help") || argc < 2) {
std::cout << options.help();
exit(0);
}
std::cout << result["var"].as<std::string>() << std::endl;
std::cout << result["exec"].as<std::filesystem::path>() << std::endl;
// auto pArgs = result["--"].as<std::vector<std::string>>();
// for (auto x : pArgs) {
// std::cout << x << std::endl;
// }
return 0;
} }