a pure Fortran 2003+ library for building elegant CLIs, inspired by Python's
argparse.
| π Argument Types Optional, required, boolean, positional, list-valued, and env-var-bound arguments |
π’ nargs Support Fixed count ( '3'), one-or-more ('+'), zero-or-more ('*') |
π Groups & Subcommands Mutually exclusive argument groups and arbitrarily nested subcommands |
π Auto-generated Output Help, usage, man page, bash completion, and Markdown β all automatic |
|---|---|---|---|
| π argparse-inspired Familiar Python-like API brought to modern Fortran |
β
POSIX compliant Standard CLI conventions respected out of the box |
π Multi-licensed GPL v3 Β· BSD 2/3-Clause Β· MIT |
π¦ Multiple build systems fpm, FoBiS, CMake, Make |
For full documentation (guide, API reference, examples, etc...) see the FLAP website.
- Stefano Zaghi β @szaghi
Contributions are welcome β see the Contributing page.
This project is distributed under a multi-licensing system:
- FOSS projects: GPL v3
- Closed source / commercial: BSD 2-Clause, BSD 3-Clause, or MIT
Anyone interested in using, developing, or contributing to this project is welcome β pick the license that best fits your needs.
program minimal
use flap
implicit none
type(command_line_interface) :: cli
character(99) :: string
integer :: error
call cli%init(description='minimal FLAP example')
call cli%add(switch='--string', switch_ab='-s', help='a string', &
required=.true., act='store', error=error)
if (error /= 0) stop
call cli%parse(error=error)
if (error /= 0) stop
call cli%get(switch='-s', val=string, error=error)
if (error /= 0) stop
print '(A)', 'String = ' // trim(string)
end program minimalSee src/tests/ for more examples including nested subcommands, mutually exclusive groups, choices, and bash completion.
Standalone β clone, fetch dependencies, and build:
git clone https://github.com/szaghi/FLAP && cd FLAP
FoBiS.py fetch # fetch PENF, FACE
FoBiS.py build -mode static-gnu # build static libraryAs a project dependency β declare FLAP in your fobos and run fetch:
[dependencies]
deps_dir = src/third_party
FLAP = https://github.com/szaghi/FLAPFoBiS.py fetch # fetch and build
FoBiS.py fetch --update # re-fetch and rebuildAdd to your fpm.toml:
[dependencies]
FLAP = { git = "https://github.com/szaghi/FLAP" }fpm build
fpm testcmake -B build && cmake --build buildmake