Open LaplaceSoda opened 1 month ago
I don't think this is a good idea. Every software treats arguments in the quotation as one argument. For example git commit -m "add some features"
, the last three words is one argument.
Actually, the numbers of argument don't matter. What I mean is wondering if this module can be updated to deal with the command included in quotation like "-n 4"
The number is important, the arguments in the quotation should not be sperated, it is what every software do.
As for your problem, I think this is one side-effect of the aggregate option argument defined in thie module, since it starts with one -
chacacter, so it is treated as something like -lah
in ls -lah
command.
If you are expected to get two arguments for "-n 4"
, then I think there are no software will do so.
If you are expected to get one arguments for "-n 4"
, then I think it is some flaw that this module cannot achieve.
Actually what I want is to get the value of argument -n
from the whole string -n 8
, which is regard as one argument in Fortran's command_argument_count()
.
In my opinion this may seems to be more like the second situation you have mentioned.
I guess you want to do the following thing:
args%add_option_integer("-n", "--number", "something number", 1)
! ...
args%get_option_integer("-n") ! if you excepte it to return 8 when you give `-n 8` in the command line
what you should do is not put them in the quotation marks.
The quotation marks in command line are only used to include space in the argument. The typical example is the git commit -m "fix some bug"
, where people want to treat the last three words as one meanful argument. So do not use the quotation marks in any other case.
Description
The arguments included in the quotation marks will be regarded as one argument both in Fortran and in this module, which means that if we use
temp.exe "-n 4"
, the functioncommand_argument_count()
will return 1 and theargparser
will not parse the argumentn
normally but return an errorError: integer option '-n' cannot be in aggregate argument
.Expected Behaviour
The effect of the command
git commit -m init
is equal togit commit "-m init"
is an example that shows the expected behavior.