szaghi / FLAP

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

Parsing default fix list of values #58

Closed ollehellman closed 7 years ago

ollehellman commented 8 years ago

Hi,

Sorry to bother you so much. I think I found a bug: running ./test_basic --string hello gives me

...
Integer list inputs:
  Input(1) = +1
  Input(2) = +140308968915872
  Input(3) = +140734567466896
...

Whereas the default values are 1 8 32. If I add --integer_list 1 2 3 everything works fine. I tracked it down, and it seems that the default separator 'args_sep' is not inserted into the default list. I could fix it by replacing

call tokenize(strin=buffer, delimiter=args_sep, toks=vals, Nt=Nv)

with

  if(.not.self%is_passed) then
    call tokenize(strin=buffer, delimiter=' ', toks=vals, Nt=Nv)
  else
    call tokenize(strin=buffer, delimiter=args_sep, toks=vals, Nt=Nv)
  endif

But that is probably not a good way of doing it. I tried figuring out the parse sobroutine, but my brain started hurting when I tried to figure out what to add.

szaghi commented 8 years ago

@ollehellman

You are not bothering at all! Thank you very much, it is absolutely a bug! Unfortunately, test coverage is still poor (70%), thus there are probably a lot of bug. Tomorrow I will fix this.

Thank you again!

szaghi commented 8 years ago

In the new v1.0.2 this should be fixed (with also the cosmetic change you highlighted into issue #57).

I also introduce a (hopefully) nice new feature: the explicit call to cli%parse method is now optional! The first time you call cli%get the parsed status is checked and, if necessary, cli%parse is automatically called. This involves a small API change (fully backward compatible): cli%get now accept also the optional argument args for passing CLAs by string.

See the new added tests test_minimal and test_hidden.

Let me know if this fix the bug also for you.

Cheers.

ollehellman commented 8 years ago

Hi,

Yes and no. All the defaults are parsed correctly, but now the -h output looks weird:

   --qpoint_grid value#1 value#2 value#3, -qg value#1 value#2 value#3
          default value 26||!||26||!||26

where I would expect

   --qpoint_grid value#1 value#2 value#3, -qg value#1 value#2 value#3
          default value 26 26 26

an easy fix perhaps?

szaghi commented 8 years ago

@ollehellman ops... the weird separators are indeed the internal flap one that are inserted by the new sanitize... it is easy to fix, later today I push a fix. Thank you for your help (you are now mentioned into the official contributors :smile: )

szaghi commented 7 years ago

This should be fixed. @ollehellman feel free to re-open it.