flag.h
Inspired by Go's flag module: https://pkg.go.dev/flag
WARNING! The design of the library is not finished and may be a subject to change.
Quick Start
Check example.c
$ make
$ ./example-c -help
Inspired by Go's flag module: https://pkg.go.dev/flag
WARNING! The design of the library is not finished and may be a subject to change.
Check example.c
$ make
$ ./example-c -help
If a boolean flag's default value was true it was not possible to toggle it as a set flag's value was hardcoded to true. This is fixed by using the negated default value in case the flag is set.
Breaks existing API?: Yes (the flag_bool
, flag_str
, etc. functions have a parameter removed)
flag_[TYPE]_default
functions added to allow the user to specify a default value on a flag, by providing its pointer handle. Similar functionality for flag_required
.
On C11-compatible machines or higher, the flag_default
macro is available (supplied via. _Generic
), which removes the need to supply a type when setting a default value on a flag.
just so if people dont know how to include it globally they can