From 579237709ab8c71691f0e60c1b44de30f8b40ea0 Mon Sep 17 00:00:00 2001 From: riasc Date: Fri, 15 Nov 2024 12:16:48 -0600 Subject: [PATCH] added workflow to call help on subcall --- cli/include/Index.hpp | 5 ++++- cli/include/Overlap.hpp | 2 +- cli/include/Subcall.hpp | 2 +- cli/src/Index.cpp | 12 ++++-------- cli/src/Overlap.cpp | 4 ++-- cli/src/main.cpp | 9 +++++++-- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/cli/include/Index.hpp b/cli/include/Index.hpp index c287110..b4d81b4 100644 --- a/cli/include/Index.hpp +++ b/cli/include/Index.hpp @@ -1,6 +1,9 @@ #ifndef GENOGROVE_INDEX_HPP #define GENOGROVE_INDEX_HPP +// Standard +#include + // Class #include "genogrove/all.hpp" #include "Subcall.hpp" @@ -10,7 +13,7 @@ class Index : public Subcall { public: - cxxopts::ParseResult parseArgs(int argc, char** argv) override; + cxxopts::Options parseArgs(int argc, char** argv) override; void execute(const cxxopts::ParseResult& args) override; }; diff --git a/cli/include/Overlap.hpp b/cli/include/Overlap.hpp index 6bca6f6..d1433d3 100644 --- a/cli/include/Overlap.hpp +++ b/cli/include/Overlap.hpp @@ -12,7 +12,7 @@ class Overlap : public Subcall { public: - cxxopts::ParseResult parseArgs(int argc, char** argv) override; + cxxopts::Options parseArgs(int argc, char** argv) override; void execute(const cxxopts::ParseResult& args) override; // getter & setter diff --git a/cli/include/Subcall.hpp b/cli/include/Subcall.hpp index ff325c7..6da2ca2 100644 --- a/cli/include/Subcall.hpp +++ b/cli/include/Subcall.hpp @@ -5,7 +5,7 @@ class Subcall { public: - virtual cxxopts::ParseResult parseArgs(int argc, char** argv) = 0; + virtual cxxopts::Options parseArgs(int argc, char** argv) = 0; virtual void execute(const cxxopts::ParseResult& args) = 0; virtual ~Subcall() = default; diff --git a/cli/src/Index.cpp b/cli/src/Index.cpp index 277fb58..d5e130f 100644 --- a/cli/src/Index.cpp +++ b/cli/src/Index.cpp @@ -1,7 +1,7 @@ #include "Index.hpp" -cxxopts::ParseResult Index::parseArgs(int argc, char** argv) { - cxxopts::Options options("index", "Index an Interval File"); +cxxopts::Options Index::parseArgs(int argc, char** argv) { + cxxopts::Options options("genogrove index", "Index an Interval File"); options.add_options() ("inputfile", "The input file to be indexed", cxxopts::value()) @@ -13,15 +13,11 @@ cxxopts::ParseResult Index::parseArgs(int argc, char** argv) { ; options.parse_positional({"inputfile"}); - cxxopts::ParseResult args = options.parse(argc, argv); + options.positional_help("inputfile"); - if(args.count("help")) { - options.help(); - } - return args; + return options; } - void Index::execute(const cxxopts::ParseResult& args) { if(args.count("inputfile")) { std::string inputfile = args["inputfile"].as(); diff --git a/cli/src/Overlap.cpp b/cli/src/Overlap.cpp index e1b88e6..5680636 100644 --- a/cli/src/Overlap.cpp +++ b/cli/src/Overlap.cpp @@ -1,6 +1,6 @@ #include "Overlap.hpp" -cxxopts::ParseResult Overlap::parseArgs(int argc, char** argv) { +cxxopts::Options Overlap::parseArgs(int argc, char** argv) { cxxopts::Options options("index", "Index an Interval File"); options.add_options() ("inputfile", "The input file to be indexed", @@ -11,7 +11,7 @@ cxxopts::ParseResult Overlap::parseArgs(int argc, char** argv) { cxxopts::value()->default_value("3")) ; options.parse_positional({"inputfile"}); - return options.parse(argc, argv); + return options; } diff --git a/cli/src/main.cpp b/cli/src/main.cpp index 4e845fa..280bef3 100644 --- a/cli/src/main.cpp +++ b/cli/src/main.cpp @@ -56,7 +56,12 @@ int main(int argc, char** argv) { } // parse additional options for the subcommand - cxxopts::ParseResult subcallArgs = command->parseArgs(argc, argv); - command->execute(subcallArgs); + cxxopts::Options subcallOptions = command->parseArgs(argc, argv); + cxxopts::ParseResult subcallArgs = subcallOptions.parse(argc, argv); + + if(subcallArgs.count("help")) { + std::cout << subcallOptions.help() << "\n"; + return 0; + } }