This commit is contained in:
Connor Olding 2019-06-25 21:45:28 -07:00
parent 7db6799f75
commit c3a8ffd73e

47
kyaa.md
View File

@ -2,21 +2,49 @@
super hacky macro hacks for parsing arguments in C.
## prerequisites
## FAQ
C99 or greater.
*Fairly Arbitrary Questions*
### Why?
kyaa exists for when the "quick 'n' dirty" isn't dirty enough.
also, it keeps argument parsing *in* main,
instead of delegating with callbacks and whatnot.
### How?
kyaa secretly wraps flag-handling in if-else statements with curly braces.
it's not a switch-case method!
kyaa instead uses `continue` to handle certain arguments.
### Should I use this?
honestly, no.
### What's in a name?
i have no idea why i called it "kyaa,"
other than it being the first thing that came to mind
that wasn't already in use by some other software.
### What do I need?
the prerequisites are:
* C99 (or greater)
standard library headers:
* `stdbool.h`
* `stdio.h`
* `stdio.h` (can be avoided by overriding `KYAA_OUT` and `KYAA_ERR`)
* `string.h`
in addition, `kyaa_extra.h` requires `limits.h`,
or at least `LONG_MIN` to be defined.
* `limits.h` (just for `kyaa_extra.h`, can be avoided by defining `LONG_MIN`)
## tutorial
ensure `argc` and `argv` are defined.
ensure `argc` and `argv` are defined in a function that returns an `int`.
kyaa doesn't actually care if it's in `main` or not.
iterate over the arguments with `KYAA_LOOP`:
@ -78,11 +106,6 @@ and `KYAA_FLAG_ARG` or `KYAA_FLAG_LONG` for flags that do:
return 0;
```
**dirty details:**
kyaa secretly wraps flag handling in if/else statements with {} blocks.
do not confuse it for a switch/case method.
kyaa uses `continue` to handle certain arguments.
kyaa handles `-h` and `--help` for printing help text.
additional help text may be defined using `KYAA_HELP`: