cclip
C/C++ Command Line Interface Parser
Installation
Github Clone
git clone https://github.com/Drew-Chase/cclip.git ./vendor/cclipGithub Submodule
git submodule add https://github.com/Drew-Chase/cclip.git ./vendor/cclipBuild
cmake build ./vendor/cclipUsage
Example
#include "cclip/options_manager.h"
#include <iostream>
int main(int argc, char **argv) {
cclip::options_manager manager("cclip test");
// Add options.
manager.add_option("h", "help", "Print this help message", false, false);
manager.add_option("v", "version", "Print the version", false, false);
manager.add_option("f", "file", "The file to read", true, true);
// Parse the command line
manager.parse(argc, argv);
if (manager.is_present("h")) { // Checks if the 'h' or 'help' option has used in the args
manager.print_help();
return 0;
}
if (manager.is_present("v")) {
std::cout << "cclip test 0.0.1" << std::endl;
return 0;
}
if (manager.is_present("f") && manager.get_option("f")->argument != nullptr) {
std::cout << "File: " << manager.get_option("f")->argument << std::endl;
}
return 0;
}options_manager Class
options_manager Classoption Struct
option StructContributing
License
Last updated