vietjtnguyen / argagg

A simple C++11 command line argument parser
MIT License
224 stars 28 forks source link

Support for options like -std=foo #23

Open Manu343726 opened 5 years ago

Manu343726 commented 5 years ago

Hi,

I would like to know if argagg could implement support for short options with =value syntax, like -std=c++11 of GCC and Clang

Manu343726 commented 5 years ago

After studying your code a bit I think this could be done by also scanning short flags for an = sign. Then if one is found assume the flag is not a combination of flags, i.e. with three flags -a, -b, -c, the following is not valid -abc=foo ("No flag named abc" error), but -a=foo is.

vietjtnguyen commented 5 years ago

This looks like a good idea since GCC supports it as is. I'll take a look at implementation, maybe this weekend.

Some notable behavior cases with GCC:

That seems to imply that support -long_name like #17 mentions is a possible solution in that one doesn't make a -std option with an argument but rather enumerates -std=c99 and -std=c11 as individual -long_name options.

vietjtnguyen commented 5 years ago

Looks like that last hypothesis regarding -std=* options being individually enumerated options rather than an argument-receiving one is correct: https://github.com/gcc-mirror/gcc/blob/48bbcd968d172c4e59d874c5fd831bcbf54cd221/gcc/c-family/c.opt#L1937-L2101