dominiklohmann / wahl

A type-safe argument parser for modern C++.

Home Page:https://dominiklohmann.github.io/wahl/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

wahl

A type-safe argument parser for modern C++.

Quick Start

Simply provide a class with fields that is to be filled by command-line arguments:

struct hello {
  static const char *help() {
    return "Simple program that greets NAME for a total of COUNT times.";
  }

  int count;
  std::string name;

  hello() : count(1) {}

  template <class F> void parse(F f) {
    f(count, "--count", "-C", wahl::help("Number of greetings."));
    f(name, "--name", "-N", wahl::help("The person to greet."),
      wahl::required());
  }

  void run() {
    for (int i = 0; i < count; i++)
      printf("%s\n", name.c_str());
  }
};

int main(int argc, const char **argv) {
  wahl::parse<hello>(argc, argv);
}

Acknowledgements

This project is derived from pfultz2/args, and I want to thank Paul Fultz II and Daniël Emmery for the idea and their work on the original library.

About

A type-safe argument parser for modern C++.

https://dominiklohmann.github.io/wahl/

License:Boost Software License 1.0


Languages

Language:C++ 82.0%Language:CMake 18.0%