1 /* Please use this file as a template when introducing new command to
5 * fixme-command-name - purpose of it
7 * Copyright (c) 20nn Example Commercial, Inc
8 * Written by Your Name <you@example.com>
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation.
14 * This program is distributed in the hope that it would be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include "closestream.h"
33 * FIXME: remove this comment.
34 * Other usage() constants that are not demonstrated below:
35 * USAGE_FUNCTIONS USAGE_COMMANDS USAGE_COLUMNS
37 static void __attribute__((__noreturn__
)) usage(void)
39 fputs(USAGE_HEADER
, stdout
);
40 printf(_(" %s [options] file...\n"), program_invocation_short_name
);
42 fputs(USAGE_SEPARATOR
, stdout
);
43 puts(_("Short program description."));
45 fputs(USAGE_OPTIONS
, stdout
);
46 puts(_(" -n, --no-argument option does not use argument"));
47 puts(_(" --optional[=<arg>] option argument is optional"));
48 puts(_(" -r, --required <arg> option requires an argument"));
49 puts(_(" -z no long option"));
50 puts(_(" --xyzzy a long option only"));
51 puts(_(" -e, --extremely-long-long-option\n"
52 " use next line for description when needed"));
53 puts(_(" -l, --long-explanation an example of very verbose, and chatty option\n"
54 " description on two, or multiple lines, where the\n"
55 " consecutive lines are intended by two spaces"));
56 puts(_(" -f, --foobar next option description resets indent"));
57 fputs(USAGE_SEPARATOR
, stdout
);
58 printf(USAGE_HELP_OPTIONS(25)); /* char offset to align option descriptions */
59 printf(USAGE_MAN_TAIL("fixme-command-name(1)"));
63 int main(int argc
, char **argv
)
68 OPT_XYZZY
= CHAR_MAX
+ 1,
69 OPT_OPTIONAL
/* see howto-man-page.txt about short option */
71 static const struct option longopts
[] = {
72 { "no-argument", no_argument
, NULL
, 'n' },
73 { "optional", optional_argument
, NULL
, OPT_OPTIONAL
},
74 { "required", required_argument
, NULL
, 'r' },
75 { "extremely-long-long-option", no_argument
, NULL
, 'e' },
76 { "xyzzy", no_argument
, NULL
, OPT_XYZZY
},
77 { "long-explanation", no_argument
, NULL
, 'l' },
78 { "foobar", no_argument
, NULL
, 'f' },
79 { "version", no_argument
, NULL
, 'V' },
80 { "help", no_argument
, NULL
, 'h' },
84 setlocale(LC_ALL
, "");
85 bindtextdomain(PACKAGE
, LOCALEDIR
);
87 close_stdout_atexit();
89 while ((c
= getopt_long(argc
, argv
, "nr:zelfVh", longopts
, NULL
)) != -1)
101 print_version(EXIT_SUCCESS
);
105 errtryhelp(EXIT_FAILURE
);