units(1): add long options
Things brings additional compatibility with units 2.10 Discussed with: wblock (man page)
This commit is contained in:
parent
f54192cc18
commit
5192ff4547
@ -13,17 +13,19 @@
|
|||||||
.Sh OPTIONS
|
.Sh OPTIONS
|
||||||
The following options are available:
|
The following options are available:
|
||||||
.Bl -tag -width indent
|
.Bl -tag -width indent
|
||||||
.It Fl f Ar filename
|
.It Fl f Ar filename No , Fl -file Ar filename
|
||||||
Specify the name of the units data file to load.
|
Specify the name of the units data file to load.
|
||||||
.It Fl q
|
.It Fl q No , Fl -quiet
|
||||||
Suppress prompting of the user for units and the display of statistics
|
Suppress prompting of the user for units and the display of statistics
|
||||||
about the number of units loaded.
|
about the number of units loaded.
|
||||||
.It Fl U
|
.It Fl U No , Fl -unitsfile
|
||||||
If the default unit file exists prints its location. If not, print
|
If the default unit file exists prints its location. If not, print
|
||||||
.Qo
|
.Qo
|
||||||
Units data file not found
|
Units data file not found
|
||||||
.Qc
|
.Qc
|
||||||
.It Fl V
|
.It Fl v No , Fl -verbose
|
||||||
|
Print the units in the conversion output. Be more verbose in general.
|
||||||
|
.It Fl V No , Fl -version
|
||||||
Print the version number, usage, and then exit.
|
Print the version number, usage, and then exit.
|
||||||
.It Ar from-unit to-unit
|
.It Ar from-unit to-unit
|
||||||
Allow a single unit conversion to be done directly from the command
|
Allow a single unit conversion to be done directly from the command
|
||||||
@ -31,8 +33,6 @@ line.
|
|||||||
The program will not print prompts.
|
The program will not print prompts.
|
||||||
It will print out the
|
It will print out the
|
||||||
result of the single specified conversion.
|
result of the single specified conversion.
|
||||||
.It Fl v
|
|
||||||
Print the units in the conversion output. Be more verbose in general.
|
|
||||||
.El
|
.El
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
The
|
The
|
||||||
|
@ -24,6 +24,7 @@ static const char rcsid[] =
|
|||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <histedit.h>
|
#include <histedit.h>
|
||||||
|
#include <getopt.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -702,6 +703,15 @@ usage(void)
|
|||||||
exit(3);
|
exit(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct option longopts[] = {
|
||||||
|
{"file", required_argument, NULL, 'f'},
|
||||||
|
{"quiet", no_argument, NULL, 'q'},
|
||||||
|
{"verbose", no_argument, NULL, 'v'},
|
||||||
|
{"unitsfile", no_argument, NULL, 'U'},
|
||||||
|
{"version", no_argument, NULL, 'V'},
|
||||||
|
{ 0, 0, 0, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
@ -718,7 +728,7 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
quiet = false;
|
quiet = false;
|
||||||
readfile = false;
|
readfile = false;
|
||||||
while ((optchar = getopt(argc, argv, "f:qvUV")) != -1) {
|
while ((optchar = getopt_long(argc, argv, "+f:qvUV", longopts, NULL)) != -1) {
|
||||||
switch (optchar) {
|
switch (optchar) {
|
||||||
case 'f':
|
case 'f':
|
||||||
readfile = true;
|
readfile = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user