From c58de07577e9d11f5570079822908525352ce0bf Mon Sep 17 00:00:00 2001 From: Gabriel Ionita Date: Fri, 24 Oct 2025 11:05:17 +0100 Subject: [PATCH] add cli options --- src/main.cpp | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 5b656c4..2782997 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,34 @@ +#include #include +#include +#include +#include +#include -int main() { - std::cout << "hello" << std::endl; +int main(int argc, char** argv) { + cxxopts::Options options("gwatch", "A command-line variable watcher"); + options.add_options() + ("var", "Symbol to watch", cxxopts::value()) + ("exec", "Executable to run", cxxopts::value()) + ("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>()->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::endl; + std::cout << result["exec"].as() << std::endl; + + // auto pArgs = result["--"].as>(); + + // for (auto x : pArgs) { + // std::cout << x << std::endl; + // } + + return 0; }