Is it possible to allow custom attributes in an fpm.toml file

So I have a program that parses the fpm.toml file to get attributes from it. When I tried just adding in a custom attribute it threw an error which I was not entirely surprised by. Is it possible, though, through some way to allow customs and it doesn’t throw an error.

See the description of the “extra” section in the documentation of the manifest file. It is specifically for adding custom fields. Note there are routines in the fpm package you can call that parse the file that you can call if you had not seen that yet

I thank you for telling me about the extras section, I didn’t know that was a thing. But I couldn’t find anything about routines for parsing, but then again my program is written in C++ so I don’t know if that affects anything. Thanks again!

Probably not easy to call from C, but fpm may be used as a dependency.
A simple example follows that creates a program called fpm-version that
will act as a plugin for fpm. Installed in your path you can see the
metadata for the project by entering

fpm version

which would produce output about the project like

name         : fpm-version
version      : 0.1.0
license      : MIT
author       : John S. Urban
maintainer   : urbanjost@comcast.net
copyright    : Copyright 2022, John S. Urban
description  : experiments with fpm plugins
categories   : fortran, fpm
keywords     : fortran, toml, fpm
homepage     : https://github.com/urbanjost
program array
!-------------------------------------------------------------------------------
! Assuming fpm is used as a dependency in the manifest file (fpm.toml):
! [executable.dependencies.fpm]
!    git = "https://github.com/fortran-lang/fpm.git"
!-------------------------------------------------------------------------------
use tomlf, only : toml_table, toml_array, get_value, toml_parse, toml_error, len
use fpm_error, only : error_t, syntax_error
use fpm_strings, only : string_t
use fpm_toml, only : toml_table, toml_key, toml_stat, get_value, get_list
implicit none
character(len=128), dimension(:), allocatable  :: arr_data
integer                       :: data_len, io, i, j
integer                       :: argument_count, argument_length, istat
type(toml_table), allocatable :: table
type(toml_array), pointer     :: arr
type(toml_error), allocatable :: parse_error
type(error_t), allocatable    :: error
type(string_t), allocatable   :: values(:)
character(len=:),allocatable  :: string, arg
character(len=256)            :: iomsg
! add call to find fpm.toml file?
  open(newunit=io, file="fpm.toml",iostat=istat,iomsg=iomsg,status='old')
  if(istat.ne.0)then
     stop trim(iomsg)
  endif
  call toml_parse(table, io, parse_error)
  close(unit=io)
  if (allocated(parse_error)) then
    print*, "Error parsing table:"//parse_error%message
  endif
  argument_count = command_argument_count()
  if(argument_count.eq.0)then
    LOOPOVER: do i=1,huge(0)-1
       select case(i)
       case(1);arg="name"
       case(2);arg="version"
       case(3);arg="license"
       case(4);arg="author"
       case(5);arg="maintainer"
       case(6);arg="copyright"
       case(7);arg="description"
       case(8);arg="categories"
       case(9);arg="keywords"
       case(10);arg="homepage"
       case default
          exit LOOPOVER
       end select
       call printarg()
    enddo LOOPOVER
  endif
contains

subroutine printarg()
   if (allocated(error))deallocate(error)
   call get_list(table, arg, values, error)
   if (allocated(error))then
      write(*,'(*(g0))')'*error* getting ',arg
   elseif(allocated(values))then
      write(*,'(a,t14,": ")',advance='no')arg
      write(*,'(*(a:,",",1x))')( values(j)%s,j=1,size(values) )
   endif
end subroutine printarg

end program