Mark functions in optfetch.c as 'static'
[OptFetch.git] / README
blobed410e8f0bc331068e946dc43b614760943f849f
1 OptFetch is a lightweight library for parsing options from the command-line.
4 OVERVIEW
6 OptFetch has just one function, fetchopts().  It takes a pointer to argc and
7 argv, and an array of opttype structs.  Each opttype struct contains a "long"
8 option name, a "short" option name, and option type, and a pointer to a
9 variable which will hold the option.  Either of the "long" and "short" options
10 may be omitted, but both may not.
13 OVERVIEW/USAGE
15 See example.c for usage.  Most of the OPTTYPES should be self-explanatory.  Do
16 note that in the case of OPTTYPE_BOOL, simply receiving the flag constitutes
17 being enabled, so if you want to do something like "--dox yes", you will have to
18 pass an OPTTYPE_STRING and do a strcmp yourself.  The library is written in ansi
19 c89, so it should work *pretty much* anywhere.
21 The function takes pointers to argc and argv because it modifies them.  It
22 removes all the flags, leaving only the arguments.  argv[0] is untouched, and
23 still corresponds to the executable name.
26 IDEAS FOR THE FUTURE
28 * Right now, both -longopt --longopt -shortopt --shortopt.  Maybe add a way to customize which are allowed?
29 * Right now, if an argument begins with "-" but it is not passed in as an option, it is passed back as an argument.  If there's an intelligent way of doing so I'd like to pass this back as an invalid flag.
30 * If a, b, and c are all OPTTYPE_BOOLs, you should be able to do -abc
31 * * But how do we reconcile if there's a longopt called "abc"?
32 * * * Could make this behaviour optional, and when it's enabled it acts similarly to getopt, where you do -shortopt, but need --longopts
33 * * If a and b are OPTTYPE_BOOLs and c is an OPTTYPE_STRING, you should be able to do -abc foo