diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2025-02-14 12:54:24 -0500 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2025-02-14 12:54:24 -0500 |
commit | 190d3fbe0f99feb8b00cef34d834c4ef5abb5262 (patch) | |
tree | b9dd8520d2e8e3a97ea6267bc06f89b25353d69b /src/lib/index/args.c | |
parent | 952de22b54c85aac5eef77d9aafe6587ad555fce (diff) | |
download | stasis-testable-entrypoint.tar.gz |
Add library stasis_index.atestable-entrypoint
Diffstat (limited to 'src/lib/index/args.c')
-rw-r--r-- | src/lib/index/args.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/lib/index/args.c b/src/lib/index/args.c new file mode 100644 index 0000000..2d92ab0 --- /dev/null +++ b/src/lib/index/args.c @@ -0,0 +1,38 @@ +#include "core.h" +#include "args.h" + +struct option long_options[] = { + {"help", no_argument, 0, 'h'}, + {"destdir", required_argument, 0, 'd'}, + {"verbose", no_argument, 0, 'v'}, + {"unbuffered", no_argument, 0, 'U'}, + {"web", no_argument, 0, 'w'}, + {0, 0, 0, 0}, +}; + +const char *long_options_help[] = { + "Display this usage statement", + "Destination directory", + "Increase output verbosity", + "Disable line buffering", + "Generate HTML indexes (requires pandoc)", + NULL, +}; + +void usage(char *name) { + const int maxopts = sizeof(long_options) / sizeof(long_options[0]); + char *opts = calloc(maxopts + 1, sizeof(char)); + for (int i = 0; i < maxopts; i++) { + opts[i] = (char) long_options[i].val; + } + printf("usage: %s [-%s] {{STASIS_ROOT}...}\n", name, opts); + guard_free(opts); + + for (int i = 0; i < maxopts - 1; i++) { + char line[255] = {0}; + sprintf(line, " --%s -%c %-20s", long_options[i].name, long_options[i].val, long_options_help[i]); + puts(line); + } + +} + |