flags icon indicating copy to clipboard operation
flags copied to clipboard

Argument validation + shortcuts

Open sailormoon opened this issue 9 years ago • 1 comments

Now that there are some basic unit tests, flag validation and multiple arguments should be added.

Currently thinking of a syntax similar to:

const flags::args args(argc, argv);
if (const auto opt = args.get_multiple<bool>("flag", "f", "no-flag", "other")) {
  const auto [argument, value] = *opt;
  // do something -- *argument will be the first of "flag", "f", or "no-flag" that matched
  // and *value will be its value.
}

for multiple arguments.

sailormoon avatar Nov 19 '16 02:11 sailormoon

Great library! Any update on defining short and long flags at the same get method? Currently I do:

const auto help = args.get("help",false) || args.get("h",false); // for booleans and int number = args.get("number",0) ; if (number == 0) number = args.get("n",2); // or pipe does not work :(

would be nice to replace that like so: const auto help = args.get({"help","h"},false); const auto number = args.get({"number","n"},2) ;

Anyway great work! Small executables and not much overhead!

mittelmark avatar Jun 15 '24 07:06 mittelmark