The USAGE_BEGIN_TAIL is removed as unnecessary.
In between command specific options and --help & --version
USAGE_SEPARATOR is inserted. For now the separator is empty line.
The USAGE_MAN_TAIL is changed to take an argument.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
description on two, or multiple lines, where the
consecutive lines are intended by two spaces
-f, --foobar next option description resets indent
+
-h, --help display this help and exit
-V, --version output version information and exit
The argument, e.g. `arg', can be better. For example if an option is
expecting number as argument a `num' is suitable argument description.
-Order of the options has no special meaning. It is good idea to write
-options that are somehow related next to each other. Usually --help and
---version, in this order, are last options in print out.
+Order of the options has no special meaning, with a exception of --help and
+--version which are expected to be last ones of the list.
Last line of the usage print out is either empty, or a message informing
about manual page. For example: `For more details see example(1).' In
*/
#define USAGE_HEADER _("\nUsage:\n")
#define USAGE_OPTIONS _("\nOptions:\n")
+#define USAGE_SEPARATOR _("\n")
#define USAGE_HELP _(" -h, --help display this help and exit\n")
#define USAGE_VERSION _(" -V, --version output version information and exit\n")
-#define USAGE_BEGIN_TAIL _("\n")
-#define USAGE_MAN_TAIL _("For more details see %s.\n")
+#define USAGE_MAN_TAIL(_man) _("\nFor more details see %s.\n"), _man
#define UTIL_LINUX_VERSION _("%s from %s\n"), program_invocation_short_name, PACKAGE_STRING
fprintf(out, " %s\n", program_invocation_short_name);
fprintf(out, USAGE_OPTIONS);
/* Additional options to here. */
+ fprintf(out, USAGE_SEPARATOR);
fprintf(out, USAGE_HELP);
fprintf(out, USAGE_VERSION);
- fprintf(out, USAGE_BEGIN_TAIL);
- /* Remove USAGE_MAN_TAIL line when man page does not exist. */
- fprintf(out, USAGE_MAN_TAIL, "arch(1)");
+ fprintf(out, USAGE_MAN_TAIL("arch(1)"));
exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
}
fprintf(out, USAGE_HEADER);
fprintf(out, _(" %s <hard|soft>\n"), program_invocation_short_name);
fprintf(out, USAGE_OPTIONS);
+ fprintf(out, USAGE_SEPARATOR);
fprintf(out, USAGE_HELP);
fprintf(out, USAGE_VERSION);
- fprintf(out, USAGE_BEGIN_TAIL);
- fprintf(out, USAGE_MAN_TAIL, "ctrlaltdel(8)");
+ fprintf(out, USAGE_MAN_TAIL("ctrlaltdel(8)"));
exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
}
fputs(_(" -Q, --queue create message queue\n"), out);
fputs(_(" -p, --mode <mode> permission for the resource (default is 0644)\n"), out);
+ fprintf(out, USAGE_SEPARATOR);
fprintf(out, USAGE_HELP);
fprintf(out, USAGE_VERSION);
- fprintf(out, USAGE_BEGIN_TAIL);
- fprintf(out, USAGE_MAN_TAIL, "ipcmk(1)");
+ fprintf(out, USAGE_MAN_TAIL("ipcmk(1)"));
exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
}
fputs(_(" -S, --semaphore-key <key> remove semaprhore by key\n"), out);
fputs(_(" -a, --all[=<shm|msg|sem>] remove all\n"), out);
fputs(_(" -v, --verbose explain what is being done\n"), out);
+ fprintf(out, USAGE_SEPARATOR);
fprintf(out, USAGE_HELP);
fprintf(out, USAGE_VERSION);
- fprintf(out, USAGE_BEGIN_TAIL);
- fprintf(out, USAGE_MAN_TAIL, "ipcrm(1)");
+ fprintf(out, USAGE_MAN_TAIL("ipcrm(1)"));
exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
}
fputs(_(" -c, --creator show creator and owner\n"), out);
fputs(_(" -l, --limits show resource limits\n"), out);
fputs(_(" -u, --summary show status summary\n"), out);
- fprintf(out, USAGE_BEGIN_TAIL);
- fprintf(out, USAGE_MAN_TAIL, "ipcs(1)");
+ fprintf(out, USAGE_MAN_TAIL("ipcs(1)"));
exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
}
fprintf(out, USAGE_HEADER);
fprintf(out, _(" %s [options] new_root put_old\n"),
program_invocation_short_name);
+ fprintf(out, USAGE_SEPARATOR);
fprintf(out, USAGE_HELP);
fprintf(out, USAGE_VERSION);
- fprintf(out, USAGE_BEGIN_TAIL);
- fprintf(out, USAGE_MAN_TAIL, "pivot_root(8)");
+ fprintf(out, USAGE_MAN_TAIL("pivot_root(8)"));
exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
}