X-Git-Url: http://git.draconx.ca/gitweb/upkg.git/blobdiff_plain/a3814af6068326e79cb5a1fd663b8280d4e57ae1..73121d6a9327147a3e2b706f0dd10e2e8cd6800f:/src/upkg.c diff --git a/src/upkg.c b/src/upkg.c index 55d13f8..6c8cbc1 100644 --- a/src/upkg.c +++ b/src/upkg.c @@ -1,19 +1,19 @@ /* - * upkg: tool for manipulating Unreal Tournament packages. - * Copyright © 2009-2011 Nick Bowler + * upkg: tool for manipulating Unreal Tournament packages. + * Copyright © 2009-2012, 2022 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 - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * 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 + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ #include @@ -34,6 +34,8 @@ #include #include +#include "help.h" + enum { MODE_INFO, MODE_LIST, @@ -44,50 +46,49 @@ enum { int verbose = 0; static const char *progname = "upkg"; -static const char *sopts = "ilxvf:VH"; -static const struct option lopts[] = { - { "info", 0, NULL, 'i' }, - { "list", 0, NULL, 'l' }, - { "export", 0, NULL, 'x' }, - { "file", 1, NULL, 'f' }, - { "verbose", 0, NULL, 'v' }, - { "version", 0, NULL, 'V' }, - { "help", 0, NULL, 'H' }, - { 0 } -}; -void print_version(void) +#include "upkgopts.h" +static const char sopts[] = SOPT_STRING; +static const struct option lopts[] = { LOPTS_INITIALIZER, {0} }; + +static void print_version(void) { printf("%s\n", PACKAGE_STRING); - puts("\ -Copyright (C) 2009 Nick Bowler.\n\ -License GPLv3+: GNU GPL version 3 or later .\n\ -This is free software: you are free to change and redistribute it.\n\ -There is NO WARRANTY, to the extent permitted by law." - ); + puts("Copyright (C) 2022 Nick Bowler."); + puts("License GPLv3+: GNU GPL version 3 or any later version."); + puts("This is free software: you are free to change and redistribute it."); + puts("There is NO WARRANTY, to the extent permitted by law."); } -void print_usage(FILE *f) +static void print_usage(FILE *f) { fprintf(f, "Usage: %s [options] [object ...]\n", progname); + if (f != stdout) + fprintf(f, "Try %s --help for more information.\n", progname); } -void print_help(void) +static void print_help(void) { + const struct option *opt; + print_usage(stdout); - puts("Detailed help coming soon. Until then, I'll just list my options."); - for (unsigned i = 0; lopts[i].name; i++) { - const struct option *o = &lopts[i]; - printf("\t--%s", o->name); - - if (o->has_arg == 1) { - printf("=val"); - } else if (o->has_arg == 2) { - printf("[=val]"); - } - printf(" (-%c)\n", o->val); + putchar('\n'); + puts("Options:"); + for (opt = lopts; opt->name; opt++) { + struct lopt_help help; + + if (!lopt_get_help(opt, &help)) + continue; + + help_print_option(opt, help.arg, help.desc, 20); } + putchar('\n'); + + puts("For more information, see the upkg(1) man page."); + putchar('\n'); + + printf("Report bugs to <%s>.\n", PACKAGE_BUGREPORT); } static void print_upkg_flags(const char *prefix, unsigned long flags)