szaghi / FLAP

Fortran command Line Arguments Parser for poor people
150 stars 34 forks source link

Duplicated CLAs #85

Closed victorsndvg closed 5 years ago

victorsndvg commented 5 years ago

Hi @szaghi ,

I'm using an old version of FLAP. In this version there is no check for duplicated CLAs from the CLI. I mean:

$ my_program --option 1 --option 2

As you can see you can use the same flag more than once and FLAP will get the latest value.

IMHO, the expected behavior in this case should be to raise or report an exception. e.g:

$ my_program --option 1 --option 2
[ERROR] --option CLA has been passed more than once

What Ist the behavior of the latest FLAP version? Users can pass the same CLA more than once? FLAP check if a CLA is passed more than once?

Thanks in advance, BR.

szaghi commented 5 years ago

Hi @victorsndvg

I do not which are the current behavior.

I'll check soon and if the duplicated CLAS will pass silently I'll try to fix, I think that an error (or at least a warning) should be raised.

victorsndvg commented 5 years ago

Thanks @szaghi !

szaghi commented 5 years ago

@victorsndvg

The current release silently pass duplicated passed CLAs.

I am working to fix it.

szaghi commented 5 years ago

@victorsndvg

I have just pushed the 1.1.9 release.

I have added a control: if multiple instances of the same non positional CLA is passed to the CLI an error is raised, e.g.:

┌╼ stefano@zaghi(04:17 PM Mon Jul 08) on master
├───╼ ~/fortran/FLAP 17 files, 164Kb
└──────╼ exe/flap_test_duplicated_clas -i 3.0 -i 5.0
test_duplicated_clas: error: switch "-i" has been passed more than once!

Let me know if this is what you want (and if there are new bugs in these new release :-)

victorsndvg commented 5 years ago

Thanks! I will check it.