The configuration that applies in directory dir (absolute).
| 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 |
absolute path of the directory |
||
| type(config_t), | intent(out) | :: | cfg |
the configuration; |
||
| integer, | intent(out) | :: | stat |
nonzero if a configuration file cannot be read |
||
| character(len=:), | intent(out), | allocatable | :: | errmsg |
what is wrong, if |
subroutine config_for(cli, cache, dir, cfg, stat, errmsg) !! The configuration that applies in directory `dir` (absolute). type(cli_t), intent(in) :: cli !! the parsed command line (`--config`, `--no-config`) type(config_cache_t), intent(inout) :: cache !! configurations found so far; `cfg` is added character(len=*), intent(in) :: dir !! absolute path of the directory type(config_t), intent(out) :: cfg !! the configuration; `cfg%path` is `''` if there is none integer, intent(out) :: stat !! nonzero if a configuration file cannot be read character(len=:), allocatable, intent(out) :: errmsg !! what is wrong, if `stat` is nonzero logical :: found integer :: k stat = 0 if (cli%no_config) then cfg%path = '' allocate (cfg%settings(0)) return end if if (len(cli%config) > 0) then call load_config(cli%config, ends_with(cli%config, 'fpm.toml'), cfg, found, stat, errmsg) if (stat == 0 .and. .not. found) then stat = 1 errmsg = cli%config//': no [extra.fformat] table' end if return end if do k = 1, size(cache%dirs) if (cache%dirs(k)%s == dir .and. len(cache%dirs(k)%s) == len(dir)) then cfg = cache%configs(k) return end if end do call find_config(dir, cfg, stat, errmsg) if (stat /= 0) return cache%dirs = [cache%dirs, string_t(dir)] cache%configs = [cache%configs, cfg] end subroutine config_for