Skip to content

Commit

Permalink
add help text to commands
Browse files Browse the repository at this point in the history
  • Loading branch information
lsproule committed Oct 29, 2023
1 parent acce799 commit 14bb23c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
22 changes: 18 additions & 4 deletions src/Command/CommandAdd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Command {
using nlohmann::json;
bool add(std::shared_ptr<Context> ctx, cxxopts::ParseResult &args) {
args.count("subcommand");
if (args.count("subcommand") != 0) {
std::string subcommand = args["subcommand"].as<std::string>();
if (subcommand == "dep") {
Expand All @@ -21,13 +20,17 @@ namespace Command {
if (subcommand == "flag") {
addFlag(ctx, args);
}
}else{
std::cout << R"EOF(
Usage add:
dep: adds a dependency
flag: adds a flag
lib: adds a library
)EOF" << std::endl;
}
return true;
}
bool addFlag(std::shared_ptr<Context> ctx, cxxopts::ParseResult &args) {
if (args.count("help")) {
std::cout << "Usage: addFlag [options] flags" << std::endl;
}
if (args.count("subcommand") == 0) {
for (auto flag : args["subcommand"].as<std::vector<std::string>>()) {
ctx->flags.push_back(flag);
Expand Down Expand Up @@ -130,6 +133,17 @@ namespace Command {
}

bool addDependency(std::shared_ptr<Context> ctx, cxxopts::ParseResult &args) {
if (args.count("args") == 0) {
std::cout << R"EOF(
Usage add dep:
[args]: the dependencies to project
cmake add dep [args]
)EOF" << std::endl;
return false;
}


for(auto arg: args.arguments()){
std::cout << arg.key() << std::endl;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Command/CommandHelp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Command {
"\t [-l | --language cpp/c]:" << ENDL
"\t initializes your project" << ENDL
"\t r | run: builds and runs your project" << ENDL
"\t add <name> <github-url> <branch-tag> : adds a dependency to your project" << ENDL
"\t add [subcommand dep lib, flags]: add library, dependency or flags to your project" << ENDL
"\t ftp: deletes the entire project" << ENDL
"\t flags: adds a flag to your project" << ENDL
"\t help: print help" << ENDL;
Expand Down
19 changes: 17 additions & 2 deletions src/Command/CommandRemove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,27 @@ namespace Command {
if (subcommand == "dep") {
removeDep(ctx, args);
}
}else{
std::cout << R"EOF(
Usage remove:
dep: removes dependencies
lib: removes libraries
flag: removes flags
)EOF" << std::endl;
}

return true;
}
bool removeDep(std::shared_ptr<Context> ctx, cxxopts::ParseResult &args) {
if (args.count("help")) {
std::cout << "Usage: remove dep [options] dep" << std::endl;

if (args.count("args") == 0) {
std::cout << R"EOF(
Usage remove dep:
[args]: the dependencies to remove
cmake remove dep [args]
)EOF" << std::endl;
return false;
}
std::vector<std::string> name_to_remove = args["args"].as<std::vector<std::string>>();
for (std::string name : name_to_remove) {
Expand Down

0 comments on commit 14bb23c

Please sign in to comment.