Parse the real command line.
Collects get_command_argument into an array and forwards to
parse_args, which holds the whole of the logic.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(cli_t), | intent(inout) | :: | this | |||
| type(error_t), | intent(inout), | optional | :: | err |
Set on a parse or validation failure. |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | private | :: | arg_index |
Bare default integer on purpose, and the one place in this module
where that is right: F2018 16.9.82 defines NUMBER, LENGTH and
STATUS of |
|||
| integer, | private | :: | arg_len |
Bare default integer on purpose, and the one place in this module
where that is right: F2018 16.9.82 defines NUMBER, LENGTH and
STATUS of |
|||
| type(string_type), | private, | allocatable | :: | args(:) | |||
| integer(kind=default_int), | private | :: | i | ||||
| integer(kind=default_int), | private | :: | n |
subroutine cli_parse(this, err) !! Parse the real command line. !! !! Collects `get_command_argument` into an array and forwards to !! `parse_args`, which holds the whole of the logic. class(cli_t), intent(inout) :: this type(error_t), intent(inout), optional :: err !! Set on a parse or validation failure. type(string_type), allocatable :: args(:) integer(default_int) :: i, n integer :: arg_index, arg_len !! Bare default integer on purpose, and the one place in this module !! where that is right: F2018 16.9.82 defines NUMBER, LENGTH and !! STATUS of `get_command_argument` as default integer, so these must !! not follow `default_int`. Under `PIC_DEFAULT_INT8` they would !! otherwise become `int64` and the call would not compile. n = int(command_argument_count(), default_int) allocate (args(n)) do i = 1_default_int, n arg_index = int(i) call get_command_argument(arg_index, length=arg_len) block character(len=arg_len) :: buffer call get_command_argument(arg_index, buffer) args(i) = buffer end block end do call this%parse_args(args, err) end subroutine cli_parse