X-Git-Url: http://git.draconx.ca/gitweb/slotifier.git/blobdiff_plain/66da2ec430dc20657579eb90289e8e5ff4f5c987..5303ccee8e8ffd09f3a07e55f5a1d1a694aeddcb:/src/slotifier.c diff --git a/src/slotifier.c b/src/slotifier.c index 05ede6b..5718386 100644 --- a/src/slotifier.c +++ b/src/slotifier.c @@ -19,17 +19,20 @@ #include #include #include -#include #include -#include -#include #include +#include + #include #include +#include +#include +#include + #include #include -#include -#include + +#include "help.h" #if !ENABLE_NLS # undef ENABLE_NLS @@ -38,16 +41,14 @@ #define _(x) (gettext(x)) +static const char *progname = "slotifier"; static unsigned verbose; -static const char *progname = "slotifier"; -static const char sopts[] = "o:vVH"; +#include "options.h" +static const char sopts[] = SOPT_STRING; static const struct option lopts[] = { - { "output", 1, NULL, 'o' }, - { "verbose", 0, NULL, 'v' }, - { "version", 0, NULL, 'V' }, - { "help", 0, NULL, 'H' }, - { 0 } + LOPTS_INITIALIZER, + {0} }; static void print_version(void) @@ -82,6 +83,7 @@ static void print_usage(FILE *f) static void print_help(void) { const struct option *opt; + print_usage(stdout); puts(_("This is \"slotifier\": a tool to convert overlapping drill hits in Excellon\n" @@ -90,63 +92,23 @@ static void print_help(void) puts(_("Options:")); for (opt = lopts; opt->val; opt++) { - const char *line, *text = "ARG"; - int w = 0; - - if (opt->has_arg) { - switch (opt->val) { - case 'o': text = _("FILE"); - } - - w += printf(_(" -%c, --%s=%s"), - opt->val, opt->name, text); - } else { - w += printf(_(" -%c, --%s"), opt->val, opt->name); - } - - if (w > 18) { - putchar('\n'); - w = 0; - } + struct lopt_help help; - switch (opt->val) { - case 'o': - text = _("Output to FILE, instead of standard output."); - break; - case 'v': - text = _("Increase verbosity (can be specified more than once)."); - break; - case 'V': - text = _("Print a version message and then exit."); - break; - case 'H': - text = _("Print this message and then exit."); - break; - default: - if (w) - putchar('\n'); + if (!lopt_get_help(opt, &help)) continue; - } - - for (line = text; line[0];) { - const char *nl = strchr(line, '\n'); - - if (!nl) { - printf("%*s%s\n", 20-w, "", line); - break; - } - printf("%*s%.*s\n", 20-w, "", (int)(nl-line), line); - line = nl+1; - } + help_print_option(opt, help.arg, help.desc, 20); } putchar('\n'); puts(_("For more information, see the slotifier(1) man page.")); putchar('\n'); - printf(_("Report bugs to <%s>."), PACKAGE_BUGREPORT); - putchar('\n'); + /* + * TRANSLATORS: Please add *another line* indicating where users should + * report translation bugs. + */ + printf(_("Report bugs to <%s>.\n"), PACKAGE_BUGREPORT); } static void init_i18n(void)