ffmt_config Module

Configuration files.

Settings (see ffmt_settings) are read from the nearest of these, searching from a file's directory upward:

  • .fformat.toml
  • fpm.toml, in an [extra.fformat] table

Settings are written as in the table of ffmt_settings, with spaces and case as tables:

indent = 3
line-length = 100
[spaces]
comma = "add"
[case]
keywords = "lower"
[files]
extensions = ["f90", "F90"]
exclude = ["build", "legacy/*.f90"]

The [files] table controls which files are formatted when a directory is given.


Uses

  • module~~ffmt_config~~UsesGraph module~ffmt_config ffmt_config module~ffmt_fs ffmt_fs module~ffmt_config->module~ffmt_fs module~ffmt_settings ffmt_settings module~ffmt_config->module~ffmt_settings module~ffmt_strings ffmt_strings module~ffmt_config->module~ffmt_strings tomlf tomlf module~ffmt_config->tomlf tomlf_constants tomlf_constants module~ffmt_config->tomlf_constants iso_c_binding iso_c_binding module~ffmt_fs->iso_c_binding module~ffmt_settings->module~ffmt_strings module~ffmt_options ffmt_options module~ffmt_settings->module~ffmt_options

Used by

  • module~~ffmt_config~~UsedByGraph module~ffmt_config ffmt_config module~ffmt_cli ffmt_cli module~ffmt_cli->module~ffmt_config

Variables

Type Visibility Attributes Name Initial
character(len=*), private, parameter :: CONFIG_NAME = '.fformat.toml'

Derived Types

type, public ::  config_t

The settings of one configuration file.

Components

Type Visibility Attributes Name Initial
type(string_t), public, allocatable :: exclude(:)

files.exclude, likewise

type(string_t), public, allocatable :: extensions(:)

files.extensions; not allocated if the file does not set it

character(len=:), public, allocatable :: path

the file, or '' if there is none

type(setting_t), public, allocatable :: settings(:)

the formatting settings, in the order they are applied


Subroutines

private subroutine empty(cfg)

A configuration with nothing set.

Arguments

Type IntentOptional Attributes Name
type(config_t), intent(out) :: cfg

set to have no file, no settings and no [files] lists

public subroutine find_config(dir, cfg, stat, errmsg)

The configuration for files in directory dir (an absolute path): from the nearest config file in dir or its parents. cfg%path is '' if there is none.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: dir

absolute path of the directory

type(config_t), intent(out) :: cfg

the configuration found

integer, intent(out) :: stat

nonzero if the config file found cannot be read

character(len=:), intent(out), allocatable :: errmsg

what is wrong, with the file name, if stat is nonzero

public subroutine load_config(path, fpm, cfg, found, stat, errmsg)

Read the configuration in file path: the whole file, or with fpm its [extra.fformat] table. found is false if an fpm.toml has no such table.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: path

the TOML file

logical, intent(in) :: fpm

path is an fpm.toml

type(config_t), intent(out) :: cfg

the configuration; empty if not found

logical, intent(out) :: found

the file has a configuration

integer, intent(out) :: stat

nonzero for bad TOML, an unknown key or a bad value

character(len=:), intent(out), allocatable :: errmsg

what is wrong, with the file name, if stat is nonzero