X-Git-Url: http://git.draconx.ca/gitweb/liblbx.git/blobdiff_plain/30e3dd045f61a8a2e0a237074e6706461c6dd2fd..efc068f39f6811cdc0e004d2acf4ef08b2b71c3e:/src/lbxtool.c diff --git a/src/lbxtool.c b/src/lbxtool.c index 3c4e436..6629969 100644 --- a/src/lbxtool.c +++ b/src/lbxtool.c @@ -1,7 +1,7 @@ /* * 2ooM: The Master of Orion II Reverse Engineering Project * Simple command-line tool to extract LBX archive files. - * Copyright © 2006-2011, 2013 Nick Bowler + * Copyright © 2006-2011, 2013-2014, 2021 Nick Bowler * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,6 +16,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + #include #include #include @@ -24,19 +25,51 @@ #include #include +#include "help.h" + #include "tools.h" #include "lbx.h" #include "error.h" -static void printusage(void) +#include "toolopts.h" +static const char sopts[] = SOPT_STRING; +static const struct option lopts[] = { LOPTS_INITIALIZER, {0} }; + +static void print_usage(FILE *f) { - puts("usage: lbxtool [-l|-x] [-v] [-f path] [file ...]"); + const char *progname = tool_invocation(); + + fprintf(f, "Usage: %s [options] [-l|-x] [file ...]\n", progname); + if (f != stdout) + fprintf(f, "Try %s --help for more information.\n", progname); } -static void printhelp(void) +static void print_help(void) { - printusage(); - puts("For now, see the man page for detailed help."); + const struct option *opt; + + print_usage(stdout); + + puts("This is \"lbxtool\": a command-line tool for manipulating the LBX archives\n" + "used in Moo2."); + + putchar('\n'); + puts("Options:"); + for (opt = lopts; opt->name; opt++) { + struct lopt_help help; + int w; + + if (!lopt_get_help(opt, &help)) + continue; + + help_print_option(opt, help.arg, help.desc, 20); + } + putchar('\n'); + + puts("For more information, see the lbxtool(1) man page."); + putchar('\n'); + + printf("Report bugs to <%s>.\n", PACKAGE_BUGREPORT); } enum { @@ -177,23 +210,6 @@ int main(int argc, char **argv) const char *file = NULL; struct lbx *lbx; - static const char *sopts = "lxf:i:vV"; - static const struct option lopts[] = { - { "list", 0, NULL, 'l' }, - { "extract", 0, NULL, 'x' }, - - { "file", 1, NULL, 'f' }, - { "index", 1, NULL, 'i' }, - - { "verbose", 0, NULL, 'v' }, - - { "version", 0, NULL, 'V' }, - { "usage", 0, NULL, 'U' }, - { "help", 0, NULL, 'H' }, - - { 0 } - }; - tool_init("lbxtool", argc, argv); while ((opt = getopt_long(argc, argv, sopts, lopts, NULL)) != -1) { switch(opt) { @@ -206,20 +222,14 @@ int main(int argc, char **argv) case 'f': file = optarg; break; - case 'i': - /* FIXME: Add index file support. */ - break; case 'v': verbose = 1; break; case 'V': tool_version(); return EXIT_SUCCESS; - case 'U': - printusage(); - return EXIT_SUCCESS; case 'H': - printhelp(); + print_help(); return EXIT_SUCCESS; default: return EXIT_FAILURE;