Clara
Clara copied to clipboard
Parsing `-j 8` but also `-j8`
Dear Clara authors,
First thanks for this lightweight cmdline parsing library. It's much appreciated after years of program_options. :wink:
I'm using Clara and I noticed that most of the time I mistype the command line argument without space between the value and the option.
Is there an easy way or could you give some hints to make a patch, so that -j 8 but also -j8 could be parsed as 8 for a case like this :
std::optional<size_t> cpus_j;
auto cmd_args =
Opt ( cpus_j, "cpus" )
["-j"]
("How many CPU cores have to be dedicated to the build.\n");
Or is it something you don't want at all in Clara ?
Warm regards,
The trouble is that, after a - multi-character arguments are treated as a series of single character options. E.g. -abc is the equivalent of passing -a -b -c.
So -j8 would be interpreted as -j -8.
If you didn't want that behaviour we could, perhaps, include an option (a #define) to disable it - in favour of your behaviour. But that would complicate things. And at the moment we have more pressing changes to make.
We do also support -j=8 and -j:8, however.
Thanks for the short response time. :+1:
We do also support -j=8 and -j:8, however.
Yes but it requires to type more for the user of the command line.
Wouldn't it be an option to have -abc work at the same time than -j8 because b and c are known as options, while 8 isn't ?
Or simply because 8 is a numeral and therefore it isn't a wish to support it as arg ?
This is now supported in Lyra as of https://github.com/bfgroup/Lyra/commit/8013cbae5a320c0c83bd9bebdde57f7f20f236d7
Hey thanks René, I‘ll try your fork! Boost philosophy is great!