First of all, thank you @urbanjost for writing this library, it's very cool.
In the process of using the M_CLI2 library, I found that the allocatable attributes of help_text and version_text do not seem to be so necessary.
Removing the allocatable attributes makes the set_args interface more lenient, allowing the user to enter an array of constant strings (character(*), parameter :: help_text(*) = [...]).
I made such a modification (a commit), and it looks like there are no apparent issues.
program main
use M_CLI2
character(*), parameter :: help_text(*) = [character(10) :: "help1", "help2"]
character(:), allocatable :: version_text(:)
version_text = [character(10) :: "version1", "version2"]
call set_args("", help_text, version_text)
end program main
Before:
>> fpm run -- --help
M_CLI2.F90 done.
libdemo.a done.
main.f90 failed.
[ 75%]Compiling...
app\main.f90:8:22:
8 | call set_args("", help_text, version_text)
| 1
Error: Actual argument at (1) to allocatable or pointer dummy argument 'help_text' must have a deferred length type parameter if
and only if the dummy has one
<ERROR> Compilation failed for object " app_main.f90.o "
<ERROR>stopping due to failed compilation
STOP 1
Had a little trouble with the github merge, but it appears to have worked this time. This makes M_CLI2 usage more general, which is a main focus of the package. Thanks!
First of all, thank you @urbanjost for writing this library, it's very cool.
In the process of using the
M_CLI2
library, I found that theallocatable
attributes ofhelp_text
andversion_text
do not seem to be so necessary.Removing the
allocatable
attributes makes theset_args
interface more lenient, allowing the user to enter an array of constant strings (character(*), parameter :: help_text(*) = [...]
). I made such a modification (a commit), and it looks like there are no apparent issues.Before:
After: