]> andersk Git - moira.git/commitdiff
Warn/help users who probably got the arguments in the wrong order:
authordanw <danw>
Thu, 10 Oct 1996 20:28:44 +0000 (20:28 +0000)
committerdanw <danw>
Thu, 10 Oct 1996 20:28:44 +0000 (20:28 +0000)
  danw@technomage:blanche> ./blanche danw -a some-list

  WARNING: "LIST:some-list" was just added to list "danw".
  If you meant to add yourself to the list "some-list", type:
          blanche danw -d some-list  (to undo this)
          blanche some-list -a danw  (to add yourself to that list)

  danw@technomage:blanche> ./blanche danw -d some-other-list
  ./blanche:  Unable to find member some-other-list to delete from danw
  (If you were trying to remove yourself from the list "some-other-list",
  the correct command is "blanche some-other-list -d danw".)

The warning message is given when the user tries to add a list to the
list with his/her username, and the help message is given when the
user tries to delete something from the list with his/her username and
it fails.

Additional, unrelated change: make the usage note document
`-db/-database' instead of `-S/-server' (to match the moira client).
The old options are still supported, just not documented.

clients/blanche/blanche.c

index 4226b13b901f903c411c33b08b29f8a8ba695478..af40c8c18f0002599f2e0bfad2cb794f05452e14 100644 (file)
@@ -17,6 +17,7 @@
 #include <mit-copyright.h>
 #include <errno.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <ctype.h>
 #include <string.h>
 #include <moira.h>
@@ -306,9 +307,18 @@ char **argv;
            membervec[1] = "LIST";
            status = mr_query("add_member_to_list", 3, membervec,
                               scream, NULL);
-           if (status == MR_SUCCESS)
-             break;
-           else if (status != MR_LIST || memberstruct->type != M_ANY) {
+           if (status == MR_SUCCESS) {
+               if (!strcmp(membervec[0], getenv("USER"))) {
+                   fprintf(stderr, "\nWARNING: \"LIST:%s\" was just added to list \"%s\".\n",
+                           membervec[2], membervec[0]);
+                   fprintf(stderr, "If you meant to add yourself to the list \"%s\", type:\n", membervec[2]);
+                   fprintf(stderr, "\tblanche %s -d %s\t(to undo this)\n",
+                           membervec[0], membervec[2]);
+                   fprintf(stderr, "\tblanche %s -a %s\t(to add yourself to that list)\n",
+                           membervec[2], membervec[0]);
+               }
+               break;
+           } else if (status != MR_LIST || memberstruct->type != M_ANY) {
                com_err(whoami, status, "while adding member %s to %s",
                        memberstruct->name, listname);
                break;
@@ -391,10 +401,15 @@ char **argv;
            membervec[1] = "STRING";
            status = mr_query("delete_member_from_list", 3, membervec,
                               scream, NULL);
-           if (status == MR_STRING && memberstruct->type == M_ANY)
+           if (status == MR_STRING && memberstruct->type == M_ANY) {
              com_err(whoami, 0, " Unable to find member %s to delete from %s",
                      memberstruct->name, listname);
-           else if (status != MR_SUCCESS)
+             if (!strcmp(membervec[0], getenv("USER"))) {
+               fprintf(stderr, "(If you were trying to remove yourself from the list \"%s\",\n", membervec[2]);
+               fprintf(stderr, "the correct command is \"blanche %s -d %s\".)\n",
+                       membervec[2], membervec[0]);
+             }
+           } else if (status != MR_SUCCESS)
              com_err(whoami, status, "while deleting member %s from %s",
                      memberstruct->name, listname);
            break;
@@ -447,7 +462,7 @@ char **argv;
     fprintf(stderr, "   -dl | -deletelist filename\n");
     fprintf(stderr, "   -f | -file filename\n");
     fprintf(stderr, "   -n | -noauth\n");
-    fprintf(stderr, "   -S | -server host[:port]\n");
+    fprintf(stderr, "   -db | -server host[:port]\n");
     fprintf(stderr, "   -D | -debug\n");
     exit(1);
 }
This page took 0.0852 seconds and 5 git commands to generate.