The options for a file in directory dir: defaults, then configuration, then command line.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(cli_t), | intent(in) | :: | cli |
the parsed command line |
||
| type(config_cache_t), | intent(inout) | :: | cache |
configurations found so far |
||
| character(len=*), | intent(in) | :: | dir |
the file's directory, relative or absolute |
||
| type(format_options_t), | intent(out) | :: | opts |
the options |
||
| integer, | intent(out) | :: | stat |
nonzero for an unreadable configuration or a bad setting |
||
| character(len=:), | intent(out), | allocatable | :: | errmsg |
what is wrong, if |
subroutine options_for(cli, cache, dir, opts, stat, errmsg) !! The options for a file in directory `dir`: defaults, then configuration, then command line. type(cli_t), intent(in) :: cli !! the parsed command line type(config_cache_t), intent(inout) :: cache !! configurations found so far character(len=*), intent(in) :: dir !! the file's directory, relative or absolute type(format_options_t), intent(out) :: opts !! the options integer, intent(out) :: stat !! nonzero for an unreadable configuration or a bad setting character(len=:), allocatable, intent(out) :: errmsg !! what is wrong, if `stat` is nonzero type(config_t) :: cfg integer :: k call config_for(cli, cache, absolute_path(dir), cfg, stat, errmsg) if (stat /= 0) return do k = 1, size(cfg%settings) call apply_setting(opts, cfg%settings(k)%key, cfg%settings(k)%value, stat, errmsg) if (stat /= 0) then errmsg = cfg%path//': '//errmsg return end if end do do k = 1, size(cli%settings) call apply_setting(opts, cli%settings(k)%key, cli%settings(k)%value, stat, errmsg) if (stat /= 0) return end do end subroutine options_for