chiark / gitweb /
watershed; Provide -h and --help options. Closes:#659989.
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 29 Nov 2013 18:41:02 +0000 (18:41 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 29 Nov 2013 18:41:02 +0000 (18:41 +0000)
cprogs/watershed.c
debian/changelog

index 3bf9b0763e3b1643e9a1cf20f0b85f08295af817..580d2204515a7c367b8cbe385f8420f7b2efe4e8 100644 (file)
 static const struct option os[]= {
   { "--state-dir", 1,0,'d' },
   { "--command-id",1,0,'i' },
 static const struct option os[]= {
   { "--state-dir", 1,0,'d' },
   { "--command-id",1,0,'i' },
+  { "--help",      0,0,'h' },
   { 0 }
 };
 
   { 0 }
 };
 
@@ -294,11 +295,17 @@ static int cohort_fd, lock_fd;
   }while(0)
 
 
   }while(0)
 
 
-static void badusage(void) {
+static void printusage(FILE *f) {
   fputs(_("usage: watershed [<options>] <command>...\n"
   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"),
          "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) {
   exit(127);
 }
 static void die(const char *m) {
@@ -330,11 +337,12 @@ static char *m_asprintf(const char *fmt, ...) {
 static void parse_args(int argc, char *const *argv) {
   int o;
   for (;;) {
 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;
     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();
     }
   }
     default: badusage();
     }
   }
index 4f71e9d2732d59bd15ad83bd74196b1a0be617d0..9627b0f5aebc457ecd2869132b40ef60e0389b6b 100644 (file)
@@ -5,6 +5,7 @@ chiark-utils (4.2.1~~iwj4) unstable; urgency=low
   * really: Document need to be in the "root" group as well.  (This is
     better than removing the restriction, because it would be dangerous to
     relax this security barrier in existing deployments.)  Closes:#693356.
   * really: Document need to be in the "root" group as well.  (This is
     better than removing the restriction, because it would be dangerous to
     relax this security barrier in existing deployments.)  Closes:#693356.
+  * watershed; Provide -h and --help options.  Closes:#659989.
 
  --
 
 
  --