summaryrefslogtreecommitdiff
path: root/berkeley/lprm.c
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2018-12-06 14:38:05 -0500
committerMichael R Sweet <michael.r.sweet@gmail.com>2018-12-06 14:38:05 -0500
commit860f3d3b1352017748657281562445be84f9a5f1 (patch)
tree7a4cfc10ddc8949208ad729a541baf10c9c7ea12 /berkeley/lprm.c
parentabc300696c0e659f1db8d8f683633a2035be1312 (diff)
downloadcups-860f3d3b1352017748657281562445be84f9a5f1.tar.gz
Add --help usage for all Berkeley commands (Issue #5326)
Diffstat (limited to 'berkeley/lprm.c')
-rw-r--r--berkeley/lprm.c44
1 files changed, 37 insertions, 7 deletions
diff --git a/berkeley/lprm.c b/berkeley/lprm.c
index d9a30459c..eefcad50b 100644
--- a/berkeley/lprm.c
+++ b/berkeley/lprm.c
@@ -1,10 +1,11 @@
/*
* "lprm" command for CUPS.
*
- * Copyright 2007-2016 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.
*/
/*
@@ -15,6 +16,13 @@
/*
+ * Local functions...
+ */
+
+static void usage(void) _CUPS_NORETURN;
+
+
+/*
* 'main()' - Parse options and cancel jobs.
*/
@@ -48,7 +56,9 @@ main(int argc, /* I - Number of command-line arguments */
for (i = 1; i < argc; i ++)
{
- if (argv[i][0] == '-' && argv[i][1] != '\0')
+ if (!strcmp(argv[i], "--help"))
+ usage();
+ else if (argv[i][0] == '-' && argv[i][1] != '\0')
{
for (opt = argv[i] + 1; *opt; opt ++)
{
@@ -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."), argv[0]);
- goto error;
+ usage();
}
cupsSetUser(argv[i]);
@@ -118,7 +128,7 @@ main(int argc, /* I - Number of command-line arguments */
if (i >= argc)
{
_cupsLangPrintf(stderr, _("%s: Error - expected hostname after \"-h\" option."), argv[0]);
- goto error;
+ usage();
}
else
cupsSetServer(argv[i]);
@@ -133,7 +143,7 @@ main(int argc, /* I - Number of command-line arguments */
default :
_cupsLangPrintf(stderr, _("%s: Error - unknown option \"%c\"."), argv[0], *opt);
- goto error;
+ usage();
}
}
}
@@ -208,3 +218,23 @@ main(int argc, /* I - Number of command-line arguments */
return (1);
}
+
+
+/*
+ * 'usage()' - Show program usage and exit.
+ */
+
+static void
+usage(void)
+{
+ _cupsLangPuts(stdout, _("Usage: lprm [options] [id]\n"
+ " lprm [options] -"));
+ _cupsLangPuts(stdout, _("Options:"));
+ _cupsLangPuts(stdout, _("- Cancel all jobs"));
+ _cupsLangPuts(stdout, _("-E Encrypt the connection to the server"));
+ _cupsLangPuts(stdout, _("-h server[:port] Connect to the named server and port"));
+ _cupsLangPuts(stdout, _("-P destination Specify the destination"));
+ _cupsLangPuts(stdout, _("-U username Specify the username to use for authentication"));
+
+ exit(1);
+}