add cli options
This commit is contained in:
parent
452d1ce082
commit
c58de07577
33
src/main.cpp
33
src/main.cpp
@ -1,5 +1,34 @@
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
#include <cxxopts.hpp>
|
||||
#include <vector>
|
||||
|
||||
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<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;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user