From 25f64b47d74c976c22ad8ee82dea958c919f3d74 Mon Sep 17 00:00:00 2001 From: riasc Date: Sat, 26 Oct 2024 22:32:05 -0500 Subject: [PATCH] create skeleton for cli --- src/main.cpp | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 2d32496..c7ee46f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,3 +1,42 @@ -// -// Created by Richard Albin Schaefer on 10/16/24. -// +#include +#include +#include +#include + +std::map parseArgs(int argc, char* argv[], std::vector& positional) { + std::map options; + + for(int i = 1; i < argc; ++i) { + std::string arg = argv[i]; + + if(arg[0] == '-') { + std::string value = ""; + + // check if there is a value for the option + if(i+1 < argc && argv[i+1][0] != '_') { + value = argv[i+1]; + } + options[arg] = value; // store option and value + } else { + // otherwise, it is a positional argument + positional.push_back(arg); + } + } + return options; +} + +int main(int argc, char* argv[]) { + std::map options = parseArgs(argc, argv); + + if(options.count("--help") || options.count("-h")) { + std::cout << "genogrove: A C++ library for the Interval B+ Tree (IBPTree) data structure" << std::endl; + std::cout << "Usage: genogrove [OPTIONS]" << std::endl; + std::cout << "Options:" << std::endl; + std::cout << " -h, --help: Print this help message" << std::endl; + std::cout << " -v, --version: Print the version of genogrove" << std::endl; + return 0; + } + + + +} \ No newline at end of file