]> git.corax.cc Git - toolbox/commit
include/opt: Add flag to define required arguments
authorMatthias Kruk <m@m10k.eu>
Sun, 18 Apr 2021 23:38:43 +0000 (08:38 +0900)
committerMatthias Kruk <m@m10k.eu>
Sun, 18 Apr 2021 23:56:01 +0000 (08:56 +0900)
commit17dbd31636d781c86767e7287b1e6d7b46e07ecf
treea7f7b96002d9bf8a52accddf2ffd8f7018c1942c
parentb036c0a1963189cc8d376c61712c622b8576741f
include/opt: Add flag to define required arguments

The opt module currently does not provide a means to define required
arguments, making it hard for the callee to determine if an argument
was provided on the commandline, or if the default value was returned
by opt_get().
This commit adds a flag to specify if an argument must be provided on
the commandline. Further, since multiple flags can now be passed to
opt_add_arg(), the flag format is changed: now, a string containing
all flags as characters must be passed. The implementation understands
the following flags:

 r - Argument is required
 v - Argument has a value (e.g. is followed by a second argument)

For example, to declare a required argument with a value, one would
pass the flags "rv".
include/opt.sh