Skip to content

Commit

Permalink
Add --help usage for all System V commands (Issue #5326)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrsweet committed Dec 6, 2018
1 parent df4101b commit 8e52928
Show file tree
Hide file tree
Showing 12 changed files with 434 additions and 237 deletions.
54 changes: 11 additions & 43 deletions man/lp.man
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
.\"
.\" lp man page 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.
.\"
.TH lp 1 "CUPS" "2 May 2016" "Apple Inc."
.TH lp 1 "CUPS" "6 December 2018" "Apple Inc."
.SH NAME
lp \- print files
.SH SYNOPSIS
Expand Down Expand Up @@ -158,44 +159,16 @@ Aside from the printer-specific options reported by the
.BR lpoptions (1)
command, the following generic options are available:
.TP 5
\fB\-o collate=true\fR
Prints collated copies.
.TP 5
\fB\-o fit\-to\-page\fR
Scales the print file to fit on the page.
.TP 5
\fB\-o job-hold-until=\fIwhen\fR
Holds the job until the specified local time.
"when" can be "indefinite" to hold the until released, "day-time" to print the job between 6am and 6pm local time, "night" to print the job between 6pm and 6am local time, "second-shift" to print the job between 4pm and 12am local time, "third-shift" to print the job between 12am and 8am local time, or "weekend" to print the job on Saturday or Sunday.
.TP 5
\fB\-o job-hold-until=\fIhh:mm\fR
Holds the job until the specified time in hours and minutes UTC.
.TP 5
\fB\-o job-priority=\fIpriority\fR
Set the priority to a value from 1 (lowest) to 100 (highest), which influences when a job is scheduled for printing.
The default priority is typically 50.
.TP 5
\fB\-o job-sheets=\fIname\fR\fR
Prints a cover page (banner) with the document.
The "name" can be "classified", "confidential", "secret", "standard", "topsecret", or "unclassified".
.TP 5
\fB\-o job-sheets=\fIstart-name,end-name\fR\fR
Prints cover pages (banners) with the document.
.TP 5
\fB\-o media=\fIsize\fR
Sets the page size to \fIsize\fR. Most printers support at least the size names "a4", "letter", and "legal".
.TP 5
\fB\-o mirror\fR
Mirrors each page.
.TP 5
\fB\-o number\-up=\fR{\fI2|4|6|9|16\fR}
Prints 2, 4, 6, 9, or 16 document (input) pages on each output page.
.TP 5
\fB\-o number\-up\-layout=\fIlayout\fR
Specifies the layout of pages with the "number-up" option.
The "layout" string can be "btlr", "btrl", "lrbt", "lrtb", "rlbt", "rltb", "tblr", or "tbrl" - the first two letters determine the column order while the second two letters determine the row order.
"bt" is bottom-to-top, "lr" is left-to-right, "rl" is right-to-left, and "tb" is top-to-bottom.
.TP 5
\fB\-o orientation\-requested=4\fR
Prints the job in landscape (rotated 90 degrees counter-clockwise).
.TP 5
Expand All @@ -205,17 +178,12 @@ Prints the job in landscape (rotated 90 degrees clockwise).
\fB\-o orientation\-requested=6\fR
Prints the job in reverse portrait (rotated 180 degrees).
.TP 5
\fB\-o outputorder=reverse\fR
Prints pages in reverse order.
\fB\-o print\-quality=3\fR
.TP 5
\fB\-o page\-border=\fIborder\fR
Prints a border around each document page.
"border" is "double", "double\-thick", "single", or "single\-thick".
\fB\-o print\-quality=4\fR
.TP 5
\fB\-o page\-ranges=\fIpage-list\fR
Specifies which pages to print in the document.
The list can contain a list of numbers and ranges (#-#) separated by commas, e.g., "1,3-5,16".
The page numbers refer to the output pages and not the document's original pages - options like "number-up" can affect the numbering of the pages.
\fB\-o print\-quality=5\fR
Specifies the output quality - draft (3), normal (4), or best (5).
.TP 5
\fB\-o sides=one\-sided\fR
Prints on one side of the paper.
Expand Down Expand Up @@ -243,10 +211,10 @@ Print a double-sided legal document to a printer called "foo":
lp -d foo -o media=legal -o sides=two-sided-long-edge filename

.fi
Print a presentation document 2-up to a printer called "foo":
Print a presentation document 2-up to a printer called "bar":
.nf

lp -d foo -o number-up=2 filename
lp -d bar -o number-up=2 filename
.fi
.SH SEE ALSO
.BR cancel (1),
Expand Down
50 changes: 9 additions & 41 deletions man/lpr.man
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
.\"
.\" lpr man page 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.
.\"
.TH lpr 1 "CUPS" "2 May 2016" "Apple Inc."
.TH lpr 1 "CUPS" "6 December 2018" "Apple Inc."
.SH NAME
lpr \- print files
.SH SYNOPSIS
Expand Down Expand Up @@ -113,44 +114,16 @@ Aside from the printer-specific options reported by the
.BR lpoptions (1)
command, the following generic options are available:
.TP 5
\fB\-o collate=true\fR
Prints collated copies.
.TP 5
\fB\-o fit\-to\-page\fR
Scales the print file to fit on the page.
.TP 5
\fB\-o job-hold-until=\fIwhen\fR
Holds the job until the specified local time.
"when" can be "indefinite" to hold the until released, "day-time" to print the job between 6am and 6pm local time, "night" to print the job between 6pm and 6am local time, "second-shift" to print the job between 4pm and 12am local time, "third-shift" to print the job between 12am and 8am local time, or "weekend" to print the job on Saturday or Sunday.
.TP 5
\fB\-o job-hold-until=\fIhh:mm\fR
Holds the job until the specified time in hours and minutes UTC.
.TP 5
\fB\-o job-priority=\fIpriority\fR
Set the priority to a value from 1 (lowest) to 100 (highest), which influences when a job is scheduled for printing.
The default priority is typically 50.
.TP 5
\fB\-o job-sheets=\fIname\fR\fR
Prints a cover page (banner) with the document.
The "name" can be "classified", "confidential", "secret", "standard", "topsecret", or "unclassified".
.TP 5
\fB\-o job-sheets=\fIstart-name,end-name\fR\fR
Prints cover pages (banners) with the document.
.TP 5
\fB\-o media=\fIsize\fR
Sets the page size to \fIsize\fR. Most printers support at least the size names "a4", "letter", and "legal".
.TP 5
\fB\-o mirror\fR
Mirrors each page.
.TP 5
\fB\-o number\-up=\fR{\fI2|4|6|9|16\fR}
Prints 2, 4, 6, 9, or 16 document (input) pages on each output page.
.TP 5
\fB\-o number\-up\-layout=\fIlayout\fR
Specifies the layout of pages with the "number-up" option.
The "layout" string can be "btlr", "btrl", "lrbt", "lrtb", "rlbt", "rltb", "tblr", or "tbrl" - the first two letters determine the column order while the second two letters determine the row order.
"bt" is bottom-to-top, "lr" is left-to-right, "rl" is right-to-left, and "tb" is top-to-bottom.
.TP 5
\fB\-o orientation\-requested=4\fR
Prints the job in landscape (rotated 90 degrees counter-clockwise).
.TP 5
Expand All @@ -160,17 +133,12 @@ Prints the job in landscape (rotated 90 degrees clockwise).
\fB\-o orientation\-requested=6\fR
Prints the job in reverse portrait (rotated 180 degrees).
.TP 5
\fB\-o outputorder=reverse\fR
Prints pages in reverse order.
\fB\-o print\-quality=3\fR
.TP 5
\fB\-o page\-border=\fIborder\fR
Prints a border around each document page.
"border" is "double", "double\-thick", "single", or "single\-thick".
\fB\-o print\-quality=4\fR
.TP 5
\fB\-o page\-ranges=\fIpage-list\fR
Specifies which pages to print in the document.
The list can contain a list of numbers and ranges (#-#) separated by commas, e.g., "1,3-5,16".
The page numbers refer to the output pages and not the document's original pages - options like "number-up" can affect the numbering of the pages.
\fB\-o print\-quality=5\fR
Specifies the output quality - draft (3), normal (4), or best (5).
.TP 5
\fB\-o sides=one\-sided\fR
Prints on one side of the paper.
Expand Down
46 changes: 39 additions & 7 deletions systemv/cancel.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/*
* "cancel" 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.
*/

/*
Expand All @@ -14,6 +15,13 @@
#include <cups/cups-private.h>


/*
* Local functions...
*/

static void usage(void) _CUPS_NORETURN;


/*
* 'main()' - Parse options and cancel jobs.
*/
Expand Down Expand Up @@ -59,7 +67,9 @@ main(int argc, /* I - Number of command-line arguments */

for (i = 1; i < argc; i ++)
{
if (argv[i][0] == '-' && argv[i][1])
if (!strcmp(argv[i], "--help"))
usage();
else if (argv[i][0] == '-' && argv[i][1])
{
for (opt = argv[i] + 1; *opt; opt ++)
{
Expand Down Expand Up @@ -88,7 +98,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]);
Expand Down Expand Up @@ -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]);
return (1);
usage();
}
else
cupsSetServer(argv[i]);
Expand All @@ -140,7 +150,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();
}
else
user = argv[i];
Expand Down Expand Up @@ -376,3 +386,25 @@ main(int argc, /* I - Number of command-line arguments */

return (0);
}


/*
* 'usage()' - Show program usage and exit.
*/

static void
usage(void)
{
_cupsLangPuts(stdout, _("Usage: cancel [options] [id]\n"
" cancel [options] [destination]\n"
" cancel [options] [destination-id]"));
_cupsLangPuts(stdout, _("Options:"));
_cupsLangPuts(stdout, _("-a 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, _("-u owner Specify the owner to use for jobs"));
_cupsLangPuts(stdout, _("-U username Specify the username to use for authentication"));
_cupsLangPuts(stdout, _("-x Purge jobs rather than just canceling"));

exit(1);
}
56 changes: 44 additions & 12 deletions systemv/cupsaccept.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/

/*
Expand All @@ -15,6 +16,13 @@
#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.
*/
Expand Down Expand Up @@ -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
{
Expand All @@ -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;
Expand Down Expand Up @@ -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]);
Expand All @@ -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]);
Expand All @@ -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];
Expand All @@ -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);
}
}
}
Expand Down Expand Up @@ -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);
}
Loading

0 comments on commit 8e52928

Please sign in to comment.