chiark / gitweb /
finalise 4.4.2
[chiark-utils.git] / cprogs / watershed.c
index 82e17dce924f84624adfc8ce6e4ca31f6c12c83b..580d2204515a7c367b8cbe385f8420f7b2efe4e8 100644 (file)
@@ -3,6 +3,8 @@
  *             unnecessary runs of idempotent commands
  *
  * watershed is Copyright 2007 Canonical Ltd
+ * written by Ian Jackson <ian@davenant.greenend.org.uk>
+ * and this version now maintained as part of chiark-utils
  *
  *
  * This program is free software; you can redistribute it and/or modify
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * See the file XXXXX for a full list of credits information (often
- * installed as XXXXX.
+ * You should have received a copy of the GNU General Public
+ * License along with this file; if not, consult the Free Software
+ * Foundation's website at www.fsf.org, or the GNU Project website at
+ * www.gnu.org.
  *
  */
 /*
 static const struct option os[]= {
   { "--state-dir", 1,0,'d' },
   { "--command-id",1,0,'i' },
+  { "--help",      0,0,'h' },
   { 0 }
 };
 
@@ -294,10 +295,17 @@ static int cohort_fd, lock_fd;
   }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"),
-         stderr);
+         "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"),
+         f);
+}
+static void badusage(void) {
+  printusage(stderr);
   exit(127);
 }
 static void die(const char *m) {
@@ -329,11 +337,12 @@ static char *m_asprintf(const char *fmt, ...) {
 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();
     }
   }