argagg icon indicating copy to clipboard operation
argagg copied to clipboard

Get rid of definition names, key by the option itself

Open vietjtnguyen opened this issue 7 years ago • 0 comments

I realized that the definition name isn't really needed. I used it because I wanted a name to key on so that you can reference the option's parse results using that name, but why not just reference the option by any one of the options' flags? So instead of

//...
  parser argparser {{
//...
      {
        "sep", {"-s", "--sep"},
        "separator (default ',')", 1},
//...
    }};
//...
  auto sep = args["sep"].as<string>(",");
//...

you can just do

//...
  parser argparser {{
//...
      {
        {"-s", "--sep"},
        "separator (default ',')", 1},
//...
    }};
//...
  auto sep = args["--sep"].as<string>(",");
  // or alternatively...
  //auto sep = args["-s"].as<string>(",");
//...

The option name isn't really used for anything else.

vietjtnguyen avatar Oct 27 '17 03:10 vietjtnguyen