FLAP v2.5.1 is out.
Fortran command Line Arguments Parser
- GitHub: GitHub - szaghi/FLAP: Fortran command Line Arguments Parser for poor people · GitHub
- Documentation: FLAP Documentation
FLAP (Fortran command Line Arguments Parser) is a pure Fortran 2018 library for building command line interfaces. You describe your command line once, with a handful of calls; FLAP parses it, reads the environment and the configuration files, checks every value, and writes the help, the errors, the man page and the shell completions.
What it covers:
- options, positionals, flags and
--x/--no-xpairs, counters, repeatable options, lists andKEY=VALUEmaps - typed values: one
getfor every integer and real kind, logicals and strings - validation: required options, choices, numeric ranges, path checks, mutually exclusive sets
- git-style commands, with aliases and shared options
- values from the command line, environment variables and INI files, with the source of each value reported
- generated help, man page, Markdown, and completion scripts for bash, zsh, fish and PowerShell
- errors with “did you mean” suggestions
- and much more…
A minimal program:
program greet
use flap
implicit none
type(command_line_interface) :: cli
character(32) :: name
integer :: times, i, error
call cli%init(progname='greet', description='Greet someone')
call cli%add(positional=.true., position=1, help='Who to greet', required=.true., metavar='NAME')
call cli%add(switch='--times', switch_ab='-t', help='How many times', def='1', min='1', max='5')
call cli%parse(error=error)
if (error /= 0) stop 1
call cli%get(position=1, val=name, error=error)
call cli%get(switch='--times', val=times, error=error)
do i = 1, times
print '(A)', 'Hello '//trim(name)
enddo
endprogram greet
FLAP builds with FoBiS, fpm, CMake or Make, is tested with GNU gfortran, NVIDIA nvfortran and Intel ifx, and is multi-licensed (GPL v3, BSD 2-Clause, BSD 3-Clause, MIT).
Feedback, issues, and contributions are welcome.
Stefano