Skip to content

Commit

Permalink
added workflow to call help on subcall
Browse files Browse the repository at this point in the history
  • Loading branch information
riasc committed Nov 15, 2024
1 parent 505b909 commit 5792377
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
5 changes: 4 additions & 1 deletion cli/include/Index.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#ifndef GENOGROVE_INDEX_HPP
#define GENOGROVE_INDEX_HPP

// Standard
#include <cstdlib>

// Class
#include "genogrove/all.hpp"
#include "Subcall.hpp"
Expand All @@ -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;

};
Expand Down
2 changes: 1 addition & 1 deletion cli/include/Overlap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cli/include/Subcall.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
12 changes: 4 additions & 8 deletions cli/src/Index.cpp
Original file line number Diff line number Diff line change
@@ -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<std::string>())
Expand All @@ -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<std::string>();
Expand Down
4 changes: 2 additions & 2 deletions cli/src/Overlap.cpp
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -11,7 +11,7 @@ cxxopts::ParseResult Overlap::parseArgs(int argc, char** argv) {
cxxopts::value<int>()->default_value("3"))
;
options.parse_positional({"inputfile"});
return options.parse(argc, argv);
return options;
}


Expand Down
9 changes: 7 additions & 2 deletions cli/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 5792377

Please sign in to comment.