diff options
author | Michael R Sweet <michael.r.sweet@gmail.com> | 2018-12-06 14:38:05 -0500 |
---|---|---|
committer | Michael R Sweet <michael.r.sweet@gmail.com> | 2018-12-06 14:38:05 -0500 |
commit | 860f3d3b1352017748657281562445be84f9a5f1 (patch) | |
tree | 7a4cfc10ddc8949208ad729a541baf10c9c7ea12 /berkeley | |
parent | abc300696c0e659f1db8d8f683633a2035be1312 (diff) |
Add --help usage for all Berkeley commands (Issue #5326)
Diffstat (limited to 'berkeley')
-rw-r--r-- | berkeley/lpq.c | 21 | ||||
-rw-r--r-- | berkeley/lpr.c | 67 | ||||
-rw-r--r-- | berkeley/lprm.c | 44 |
3 files changed, 108 insertions, 24 deletions
diff --git a/berkeley/lpq.c b/berkeley/lpq.c index 7392d59ca..9c4aa116d 100644 --- a/berkeley/lpq.c +++ b/berkeley/lpq.c @@ -1,10 +1,11 @@ /* * "lpq" 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. */ /* @@ -67,6 +68,8 @@ main(int argc, /* I - Number of command-line arguments */ { interval = atoi(argv[i] + 1); } + else if (!strcmp(argv[i], "--help")) + usage(); else if (argv[i][0] == '-') { for (opt = argv[i] + 1; *opt; opt ++) @@ -635,8 +638,14 @@ show_printer(const char *command, /* I - Command name */ static void usage(void) { - _cupsLangPuts(stderr, - _("Usage: lpq [-P dest] [-U username] [-h hostname[:port]] " - "[-l] [+interval]")); + _cupsLangPuts(stderr, _("Usage: lpq [options] [+interval]")); + _cupsLangPuts(stdout, _("Options:")); + _cupsLangPuts(stdout, _("-a Show jobs on all destinations")); + _cupsLangPuts(stdout, _("-E Encrypt the connection to the server")); + _cupsLangPuts(stdout, _("-h server[:port] Connect to the named server and port")); + _cupsLangPuts(stdout, _("-l Show verbose (long) output")); + _cupsLangPuts(stdout, _("-P destination Show status for the specified destination")); + _cupsLangPuts(stdout, _("-U username Specify the username to use for authentication")); + exit(1); } diff --git a/berkeley/lpr.c b/berkeley/lpr.c index d4fc519e2..a9aed3ca4 100644 --- a/berkeley/lpr.c +++ b/berkeley/lpr.c @@ -1,10 +1,11 @@ /* * "lpr" command for CUPS. * - * Copyright 2007-2017 by Apple Inc. - * Copyright 1997-2007 by Easy Software Products. + * Copyright © 2007-2018 by Apple Inc. + * Copyright © 1997-2007 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 send files for printing. */ @@ -51,7 +59,9 @@ main(int argc, /* I - Number of command-line arguments */ for (i = 1; i < argc; i ++) { - if (argv[i][0] == '-') + if (!strcmp(argv[i], "--help")) + usage(); + else if (argv[i][0] == '-') { for (opt = argv[i] + 1; *opt; opt ++) { @@ -77,7 +87,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPrintf(stderr, _("%s: Error - expected username after \"-U\" option."), argv[0]); - return (1); + usage(); } cupsSetUser(argv[i]); @@ -97,7 +107,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPrintf(stderr, _("%s: Error - expected hostname after \"-H\" option."), argv[0]); - return (1); + usage(); } else cupsSetServer(argv[i]); @@ -123,7 +133,7 @@ main(int argc, /* I - Number of command-line arguments */ _cupsLangPrintf(stderr, _("%s: Error - expected value after \"-%c\" " "option."), argv[0], ch); - return (1); + usage(); } } @@ -149,7 +159,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPrintf(stderr, _("%s: Error - expected option=value after \"-o\" option."), argv[0]); - return (1); + usage(); } num_options = cupsParseOptions(argv[i], num_options, &options); @@ -200,7 +210,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPrintf(stderr, _("%s: Error - expected destination after \"-P\" option."), argv[0]); - return (1); + usage(); } printer = argv[i]; @@ -238,7 +248,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPrintf(stderr, _("%s: Error - expected copies after \"-#\" option."), argv[0]); - return (1); + usage(); } num_copies = atoi(argv[i]); @@ -268,7 +278,7 @@ main(int argc, /* I - Number of command-line arguments */ if (i >= argc) { _cupsLangPrintf(stderr, _("%s: Error - expected name after \"-%c\" option."), argv[0], ch); - return (1); + usage(); } title = argv[i]; @@ -408,3 +418,38 @@ main(int argc, /* I - Number of command-line arguments */ return (0); } + + +/* + * 'usage()' - Show program usage and exit. + */ + +static void +usage(void) +{ + _cupsLangPuts(stdout, _("Usage: lpr [options] [file(s)]")); + _cupsLangPuts(stdout, _("Options:")); + _cupsLangPuts(stdout, _("-# num-copies Specify the number of copies to print")); + _cupsLangPuts(stdout, _("-E Encrypt the connection to the server")); + _cupsLangPuts(stdout, _("-H server[:port] Connect to the named server and port")); + _cupsLangPuts(stdout, _("-m Send an email notification when the job completes")); + _cupsLangPuts(stdout, _("-o option[=value] Specify a printer-specific option")); + _cupsLangPuts(stdout, _("-o job-sheets=standard Print a banner page with the job")); + _cupsLangPuts(stdout, _("-o media=size Specify the media size to use")); + _cupsLangPuts(stdout, _("-o number-up=N Specify that input pages should be printed N-up (1, 2, 4, 6, 9, and 16 are supported)")); + _cupsLangPuts(stdout, _("-o orientation-requested=N\n" + " Specify portrait (3) or landscape (4) orientation")); + _cupsLangPuts(stdout, _("-o print-quality=N Specify the print quality - draft (3), normal (4), or best (5)")); + _cupsLangPuts(stdout, _("-o sides=one-sided Specify 1-sided printing")); + _cupsLangPuts(stdout, _("-o sides=two-sided-long-edge\n" + " Specify 2-sided portrait printing")); + _cupsLangPuts(stdout, _("-o sides=two-sided-short-edge\n" + " Specify 2-sided landscape printing")); + _cupsLangPuts(stdout, _("-q Specify the job should be held for printing")); + _cupsLangPuts(stdout, _("-r Remove the file(s) after submission")); + _cupsLangPuts(stdout, _("-P destination Specify the destination")); + _cupsLangPuts(stdout, _("-T title Specify the job title")); + _cupsLangPuts(stdout, _("-U username Specify the username to use for authentication")); + + exit(1); +} 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); +} |