-
Notifications
You must be signed in to change notification settings - Fork 36
Description
Dear @szaghi
I believe something strange is happening when passing known and unknown arguments together.
I believe that problem is located in flap_command_line_arguments_group_t.f90 lines 412-421. I may be wrong...
Consider following simple program
program flap_test_basic
use iso_fortran_env, only: output_unit
use flap, only : command_line_interface
use penf
implicit none
type(command_line_interface) :: cli !< Command Line Interface (CLI).
integer(I4P) :: val
val = -1
call cli%init(ignore_unknown_clas=.true., disable_hv=.true.)
call cli%add(switch='--integer',switch_ab='-i',required=.false.,def='-2',act='store')
call cli%parse()
if(cli%is_passed(switch='-i')) then
write(output_unit, '(a)') "switch='-i' is passed"
call cli%get(val=val, switch='-i')
endif
call cli%free()
write(output_unit, '(a, i0)') "integer = ",val
endprogram flap_test_basicRunning it while passing arguments in different order produces different results.
Passing known argument first:
./flap_test_basic -i 2 -s asd -ss qwe./flap_test_basic: error: switch "-s" is unknown!
switch='-i' is passed
integer = 2Somehow nothing is said about unknown arguments asd, -ss and qwe
But integer value is getting extracted correctly
Next, passing known argument second:
./flap_test_basic -s asd -i 2 -ss qwe./flap_test_basic: error: switch "-s" is unknown!
./flap_test_basic: error: switch "asd" is unknown!
./flap_test_basic: error: switch "-ss" is unknown!
switch='-i' is passed
integer = 2In this example we are only missing ./flap_test_basic: error: switch "qwe" is unknown! error message
Once again, known integer value is getting extracted correctly
Finally, passing known argument last:
./flap_test_basic -s asd -ss qwe -i 2./flap_test_basic: error: switch "-s" is unknown!
./flap_test_basic: error: switch "asd" is unknown!
./flap_test_basic: error: switch "-ss" is unknown!
integer = -1Known argument is not getting extracted at all. cli%is_passed(switch='-i') returns False.