Skip to content

BigRedEye/cpparg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cpparg

Build Status GitHub tag license

Yet another single header command line arguments parser.

Example

#include <cpparg/cpparg.h>
#include <filesystem>

int main(int argc, const char** argv) {
    cpparg::parser parser("Example parser");
    parser.title("Some title");
    
    std::string name;
    parser
        .add('n', "name")
        .optional()
        .value_type("STRING")
        .default_value("Bob")
        .description("Bob's name")
        .store(name);
        
    int i;
    parser
        .positional("i")
        .required()
        .description("Positional interger")
        .value_type("INTEGER")
        .store(i);
        
    parser
        .add("delete")
        .optional()
        .value_type("DIR")
        .description("Directory to delete")
        .default_value("/")
        .handle([](std::string_view dir) {
            std::filesystem::remove(dir);
        });
        
    std::vector<int> free_args;
    parser
        .free_arguments("ints")
        .unlimited()
        .store(free_args);
        
    parser.add_help('h', "help");
    parser.parse(argc, argv);
}

Requirements

  • Compiler with C++17 support
  • CMake (optional)

Installation

Manual

Just put cpparg.h somewhere inside your build tree and include it.

CMake
  • Clone this repository
git clone https://github.com/BigRedEye/cpparg.git
  • Add the following in your CMakeLists.txt:
add_subdirectory(cpparg)

target_link_libraries(YOUR_TARGET PUBLIC cpparg)

Usage

TODO

About

Yet another command line arguments parser

Resources

License

Stars

Watchers

Forks

Packages

No packages published