/* A description of the non-option arguments we accept. */
static const char args_doc[] = "";
+/*
+ * Define integer key provided by the usage option to the option parser as a
+ * non-ASCII character, so that it doesn't display a short option.
+ */
+#define USAGE_KEY 0x123
+
/* The options we understand. */
static struct argp_option argp_options[] = {
{"bsm", 'b', "value", OPTION_ARG_OPTIONAL, "Get/Set Backup Switch Mode (BSM)", 0},
{"dev", 'd', "path", 0, "RTC device path (optional)", 0},
{"test", 't', 0, 0, "Test RTC", 0},
+ /*
+ * Add -h manually; OPTION_HIDDEN prevents it from appearing twice in --help.
+ * This must be listed after all other options, to prevent an empty line.
+ */
+ {NULL, 'h', 0, OPTION_HIDDEN, "Give this help list", -1},
{ 0 }
};
case 'd':
options.rtc_path = arg;
break;
+ case 'h':
+ /* ARGP_HELP_STD_HELP prints the full help and exits the program */
+ argp_state_help(state, state->out_stream, ARGP_HELP_STD_HELP);
+ break;
case ARGP_KEY_ARG:
/* We do not support any arguments after the options. */
argp_usage(state);