Closed zbeekman closed 9 years ago
Weird… I don’t have anymore time to work on figuring this out today. I think maybe it is related to this: http://stackoverflow.com/questions/23995529/select-type-with-unlimited-polymorphic-pointer-to-character-variable
Hi @zbeekman thank you for the test. I have not yet tested with gfortran5 (I think). I will fix it the next week.
Have you tried doing this with 4.9? The problem may be present there too… I’m not sure. Have a good weekend!
Yes, on travis all tests should work, also the man page Generation. Maybe the problem is into the default value (that i think is not tested in travis).
Have a good week, I am going to "sleep" with Angelica ... crying
Yes, on travis test is done with explicit name not the default value https://github.com/szaghi/FLAP/blob/master/fobos#L288
yes the tests don’t try to use the default value for strings AFAICT. Good luck getting some sleep.
this seems like it might be fixed from the latest round of commits… still investigating…
OK… I think the source of this bug might be me! I was under the impression that I could specify --man_file
without giving it an argument, and that the default value would be used. But it appears that the default value is only used when the switch is not passed at all.
Often UNIX programs will have switches that can be passed without any arguments causing them to enable a certain behavior or feature with some default value. If the switch is passed with an argument then the argument overrides the default. In the case where the CLA is actually just the null string (e.g., my_prog --switch_optional_arg --some_other_switch
vs my_prog --switch_optional_arg 'foo’ --some_other_switch
) rather than overwriting the default value with the null string, you just keep the default value. Maybe you need to add another 'action' to cli%add
to say store_if_not_null or something like that…
@zbeekman
Yesterday I saw that, but your firdt guess was rigth: for this specific case it should work as you supposed, namely if you pass --man_file
without value the default one must be used. As soon as I arrive to office I fix this bug. Thank you for finding it!
Fixed.
I have introduced a new action: action='store*'
. If it is set, the named option can be invoked also without a value and in this case the value is retrieved by the default one. Note that if the default is not set errors can occur when invoking the get
method. Some special rules holds for store*
, see https://github.com/szaghi/FLAP/wiki/CLI-Method-add.
Now the Test_Driver works as expected: if --man_page
is passed without a file name it is saved on Test_Driver.1
that is the default value.
I am closing this issue, but open a new one if this feature is bugged or not conforming your request.
so, just to clarify… action='store*'
is required/mandatory to be able to use options like --man_file
without passing an additional argument?
i.e.,
call cli%add(switch='--man_file',act='store*',def='Test_Driver.1',required=.false.,help='help string')
when called as Test_Driver/Test_driver --man_file
will produce Test_Driver.1
BUT
call cli%add(switch='--man_file',act='store',def='Test_Driver.1',required=.false.,help='help string')
will produce an error if called the same way: Test_Driver/Test_driver —man_file
?
@zbeekman yes.
I am running away... see you tomorrow!
Hi @szaghi have you tried running the
Test_Driver
program with the--man_file
argument, but letting it try to use the default value?I modified one of the last lines of the Test_Driver source to also print the value being returned by
cli%get(switch='--man_file'…)
and as you can see, there is a problem returning the default value which is listed asTest_Driver.1