Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Parsing -j 8 but also -j8 #70

Open
daminetreg opened this issue Aug 26, 2018 · 4 comments
Open

Parsing -j 8 but also -j8 #70

daminetreg opened this issue Aug 26, 2018 · 4 comments

Comments

@daminetreg
Copy link

daminetreg commented Aug 26, 2018

Dear Clara authors,

First thanks for this lightweight cmdline parsing library. It's much appreciated after years of program_options. 😉

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,

@philsquared
Copy link
Collaborator

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.

@daminetreg
Copy link
Author

Thanks for the short response time. 👍

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 ?

@grafikrobot
Copy link

This is now supported in Lyra as of bfgroup/Lyra@8013cba

@daminetreg
Copy link
Author

Hey thanks René, I‘ll try your fork! Boost philosophy is great!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants