cxxopts icon indicating copy to clipboard operation
cxxopts copied to clipboard

Vector input needs brackets on CLI

Open PuneetKohli opened this issue 5 years ago • 7 comments

The README shows that to pass in a vector we need to do something like

--my_list=1,-2.1,3,4.5

whereas this does not work.

We need to do,

--my_list={1,-2.1,3,4.5}

for the library to parse correctly. Otherwise it will only parse the first value.

I can make a PR to fix the readme if the author or other users also verify this.

PuneetKohli avatar Oct 30 '19 21:10 PuneetKohli

@jarro2783 ?

PuneetKohli avatar Nov 07 '19 08:11 PuneetKohli

Sorry I missed this one. I think the first should actually work. There is code that looks like it might do it, so clearly there is a bug.

jarro2783 avatar Nov 08 '19 07:11 jarro2783

I noticed the first does appear to work fine in the examples, but like @PuneetKohli I couldn't replicate the same behaviour when including in my own project, at least out of the box (apologies I didn't look any further).

wardw avatar Feb 10 '20 20:02 wardw

@wardw If it helps, I'm just using the 2nd option right now everywhere in my code.

PuneetKohli avatar Feb 12 '20 09:02 PuneetKohli

+1 for @wardw . Option 2 works

tokr-bit avatar May 28 '20 07:05 tokr-bit

Can you show me some code that reproduces this. Using the example file I get this:

src/example --vector=1,2,3,4
vector = 1, 2, 3, 4,

so it looks like it's working.

jarro2783 avatar May 28 '20 09:05 jarro2783

hello, IMHO the problem with the example is that in the sequence 1,-2.1,3,4.5 the values are of different types: the 1st one is an integer, the second one is a floating point number

alsam avatar Jun 04 '20 12:06 alsam