static const struct option os[]= {
{ "--state-dir", 1,0,'d' },
{ "--command-id",1,0,'i' },
+ { "--help", 0,0,'h' },
{ 0 }
};
}while(0)
-static void badusage(void) {
+static void printusage(FILE *f) {
fputs(_("usage: watershed [<options>] <command>...\n"
- "options: -d|--state-dir <directory> -i|--command-id <id>\n"
+ "options:\n"
+ " -d|--state-dir <directory>\n"
+ " -i|--command-id <id>\n"
+ " -h|--help\n"
"see /usr/share/doc/chiark-utils-bin/watershed.txt\n"),
- stderr);
+ f);
+}
+static void badusage(void) {
+ printusage(stderr);
exit(127);
}
static void die(const char *m) {
static void parse_args(int argc, char *const *argv) {
int o;
for (;;) {
- o= getopt_long(argc, argv, "+d:i:", os,0);
+ o= getopt_long(argc, argv, "+d:i:h", os,0);
if (o==-1) break;
switch (o) {
case 'd': state_dir= optarg; break;
case 'i': command_id= optarg; break;
+ case 'h': printusage(stdout); exit(0); break;
default: badusage();
}
}