]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - systemv/cupsaccept.c
Add --help usage for all System V commands (Issue #5326)
[thirdparty/cups.git] / systemv / cupsaccept.c
index 7d597b386dba1688f09aab69253610c5bba37021..22fb01be1935dd4a82f6b8b70e12eaa6c6e46f32 100644 (file)
@@ -2,10 +2,11 @@
  * "cupsaccept", "cupsdisable", "cupsenable", and "cupsreject" commands for
  * CUPS.
  *
- * Copyright 2007-2017 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
+ * Copyright © 2007-2018 by Apple Inc.
+ * Copyright © 1997-2006 by Easy Software Products.
  *
- * Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
+ * Licensed under Apache License v2.0.  See the file "LICENSE" for more
+ * information.
  */
 
 /*
 #include <cups/cups-private.h>
 
 
+/*
+ * Local functions...
+ */
+
+static void    usage(const char *command) _CUPS_NORETURN;
+
+
 /*
  * 'main()' - Parse options and accept/reject jobs or disable/enable printers.
  */
@@ -46,13 +54,13 @@ main(int  argc,                             /* I - Number of command-line arguments */
 
   cancel = 0;
 
-  if (!strcmp(command, "cupsaccept") || !strcmp(command, "accept"))
+  if (!strcmp(command, "cupsaccept"))
     op = CUPS_ACCEPT_JOBS;
-  else if (!strcmp(command, "cupsreject") || !strcmp(command, "reject"))
+  else if (!strcmp(command, "cupsreject"))
     op = CUPS_REJECT_JOBS;
-  else if (!strcmp(command, "cupsdisable") || !strcmp(command, "disable"))
+  else if (!strcmp(command, "cupsdisable"))
     op = IPP_PAUSE_PRINTER;
-  else if (!strcmp(command, "cupsenable") || !strcmp(command, "enable"))
+  else if (!strcmp(command, "cupsenable"))
     op = IPP_RESUME_PRINTER;
   else
   {
@@ -68,7 +76,9 @@ main(int  argc,                               /* I - Number of command-line arguments */
 
   for (i = 1; i < argc; i ++)
   {
-    if (!strcmp(argv[i], "--hold"))
+    if (!strcmp(argv[i], "--help"))
+      usage(command);
+    else if (!strcmp(argv[i], "--hold"))
       op = IPP_HOLD_NEW_JOBS;
     else if (!strcmp(argv[i], "--release"))
       op = IPP_RELEASE_HELD_NEW_JOBS;
@@ -98,7 +108,7 @@ main(int  argc,                              /* I - Number of command-line arguments */
                if (i >= argc)
                {
                  _cupsLangPrintf(stderr, _("%s: Error - expected username after \"-U\" option."), command);
-                 return (1);
+                 usage(command);
                }
 
                cupsSetUser(argv[i]);
@@ -121,7 +131,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
                if (i >= argc)
                {
                  _cupsLangPrintf(stderr, _("%s: Error - expected hostname after \"-h\" option."), command);
-                 return (1);
+                 usage(command);
                }
 
                cupsSetServer(argv[i]);
@@ -140,7 +150,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
                if (i >= argc)
                {
                  _cupsLangPrintf(stderr, _("%s: Error - expected reason text after \"-r\" option."), command);
-                 return (1);
+                 usage(command);
                }
 
                reason = argv[i];
@@ -149,7 +159,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
 
          default :
              _cupsLangPrintf(stderr, _("%s: Error - unknown option \"%c\"."), command, *opt);
-             return (1);
+             usage(command);
        }
       }
     }
@@ -220,3 +230,25 @@ main(int  argc,                            /* I - Number of command-line arguments */
 
   return (0);
 }
+
+
+/*
+ * 'usage()' - Show program usage and exit.
+ */
+
+static void
+usage(const char *command)             /* I - Command name */
+{
+  _cupsLangPrintf(stdout, _("Usage: %s [options] destination(s)"), command);
+  _cupsLangPuts(stdout, _("Options:"));
+  _cupsLangPuts(stdout, _("-E                      Encrypt the connection to the server"));
+  _cupsLangPuts(stdout, _("-h server[:port]        Connect to the named server and port"));
+  _cupsLangPuts(stdout, _("-r reason               Specify a reason message that others can see"));
+  _cupsLangPuts(stdout, _("-U username             Specify the username to use for authentication"));
+  if (!strcmp(command, "cupsdisable"))
+    _cupsLangPuts(stdout, _("--hold                  Hold new jobs"));
+  if (!strcmp(command, "cupsenable"))
+    _cupsLangPuts(stdout, _("--release               Release previously held jobs"));
+
+  exit(1);
+}