descriptionLightweight C library for getting arguments from the command line.
ownerelronnd@protonmail.ch
last changeThu, 12 Mar 2020 16:12:01 +0000 (12 09:12 -0700)
content tags
add:
README
OptFetch is a lightweight library for parsing options from the command-line.

It should be considered complete at this point; if no modifications have been
for a long time, it is because there are no more modifications to make.  Any
bugs or obvious deficiencies will be fixed; aside from that, I consider it done.


OVERVIEW
Watch:

bool debug;
char *name;
float boat;
struct opttype opts[] = {
	{"debug", 'd', OPTTYPE_BOOL, &debug},
	{"name", 'n', OPTTYPE_STRING, &name},
	{"boat", 'b', OPTTYPE_FLOAT, &boat},
	{0}
};
fetchopts(&argc, &argv, opts);

Now wasn't that easy?

C89.  No allocations or VLAs.  See example.c for further minutiae, and
optfetch.h for the full list of argument types.


MOTIVATION
Right now, there are quite a few argument-parsing libraries.  Unfortunately,
none of them are very useful to their consumers.  This is because they are too
complicated and flexible.  This makes the library user do entirely too much work
just to get a couple of toggleable flags; yet, at the same time, it doesn't
offer very much to applications with complicated argument-parsing needs.  The
latter group would be best-served by a home-rolled parser.  This project
provides a simple solution for the former group that doesn't get in the way.
shortlog
2020-03-12 MoonchildCleanup code. Remove VLAs. Support c89.master
2019-09-22 ElronndUpdate docs
2019-08-27 ElronndNotice about doneness
2019-07-10 ElronndFix: we're using c99 features in some places, so use...
2017-12-23 ElronndUse char* instead of char[] for format_specifier
2017-12-23 ElronndSwitch to a for loop instead of a while in countopts()
2017-12-23 ElronndRemove a couple of superfluous lines so I can say ...
2017-07-16 ElronndSwitch over to c99 because apparently structs initializ...
2017-07-06 ElronndOops...Add static back to dbprintf
2017-07-06 ElronndRename dprintf to dbprintf. dprintf is apparently...
2017-07-06 ElronndDon't include stdint.h from optfetch.h. This is suppos...
2017-07-06 ElronndAdd a static target
2017-07-06 ElronndAdd -g0 to release cflags. A bit pointless I know...
2017-07-06 ElronndMark functions in optfetch.c as 'static'
2017-07-05 ElronndCut README off at 80 lines, because apparently repo...
2017-07-05 ElronndRename DOCUMENTATION to README, update a bit
...
heads
4 years ago master