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"
32 static void __attribute__((__noreturn__
)) usage(FILE *out
)
34 fputs(USAGE_HEADER
, out
);
35 fprintf(out
, _(" %s [options] file...\n"), program_invocation_short_name
);
36 fputs(USAGE_OPTIONS
, out
);
37 fputs(_(" -n, --no-argument option does not use argument\n"), out
);
38 fputs(_(" --optional[=<arg>] option argument is optional\n"), out
);
39 fputs(_(" -r, --required <arg> option requires an argument\n"), out
);
40 fputs(_(" -z no long option\n"), out
);
41 fputs(_(" --xyzzy a long option only\n"), out
);
42 fputs(_(" -e, --extremely-long-long-option\n"), out
);
43 fputs(_(" use next line for description when needed\n"), out
);
44 fputs(_(" -l, --long-explanation an example of very verbose, and chatty option\n"), out
);
45 fputs(_(" description on two, or multiple lines, where the\n"), out
);
46 fputs(_(" consecutive lines are intended by two spaces\n"), out
);
47 fputs(_(" -f, --foobar next option description resets indent\n"), out
);
48 fputs(USAGE_SEPARATOR
, out
);
49 fputs(USAGE_HELP
, out
);
50 fputs(USAGE_VERSION
, out
);
51 fprintf(out
, USAGE_MAN_TAIL("fixme-command-name(1)"));
52 exit(out
== stderr
? EXIT_FAILURE
: EXIT_SUCCESS
);
55 int main(int argc
, char **argv
)
60 OPT_XYZZY
= CHAR_MAX
+ 1,
61 OPT_OPTIONAL
/* see howto-man-page.txt about short option */
63 static const struct option longopts
[] = {
64 {"no-argument", no_argument
, NULL
, 'n'},
65 {"required", required_argument
, NULL
, 'r'},
66 {"xyzzy", no_argument
, NULL
, OPT_XYZZY
},
67 {"extremely-long-long-option", no_argument
, NULL
, 'e'},
68 {"long-explanation", no_argument
, NULL
, 'l'},
69 {"foobar", no_argument
, NULL
, 'f'},
70 {"version", no_argument
, NULL
, 'V'},
71 {"help", no_argument
, NULL
, 'h'},
75 setlocale(LC_ALL
, "");
76 bindtextdomain(PACKAGE
, LOCALEDIR
);
80 while ((c
= getopt_long(argc
, argv
, "nr:elfVh", longopts
, NULL
)) != -1)
91 printf(UTIL_LINUX_VERSION
);
96 errtryhelp(EXIT_FAILURE
);