bug-inetutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

unifying common options


From: Marcus Brinkmann
Subject: unifying common options
Date: Fri, 17 Aug 2001 03:20:54 +0200
User-agent: Mutt/1.3.20i

Hi,

I think we should make it easier to unify common options --help, --usage,
--version, probably --license.

I like much the style I used in syslogd, and made a lot of changes to most
other programs to behave the same way (issues are what to print on what
occasion, where to print it, and what exit status to return).  ping is a bit out
of line, but it is in some respects more complete, like it provides a
license option which is actually a good idea.  Some of the old bsd stuff is
out of line (completely).

This screams for unification, probably in a small library that is linked in
statically.

This would all be easier if we could use argp from the GNU C library.  I
think it can also be included in the package for systems that are not glibc
based.  argp is mega cool, we use it in the Hurd a lot, however, it is
probably overkill.  If argp is not feasible, I suggest the following:

Common options are --help, --usage, --version, --license.
No short versions are defined, but a program might do this itself.
If the command line does contain either of --help, --version, --usage,
--license, the corresponding stuff is output to stdout, with exit status 0.
If multiple of the above are provided, it is undefined which is
printed, but exactly one is.  Probably the first one.

If the command line does not contain --help/--version/--usage and is
syntactically invalid, a short usage is printed on stderr, and exit status
is != 0.

My style as I used it reflects the limitation of the current
headers/version.h, which only has package name, version and bug address
(note the formatting, also where the argv[0] is used and where the
program name. This is probably wrong.  In help and usage, we should use
argv[0] everywhere?):

$ ./syslogd --version
syslogd (GNU inetutils) 1.3.2f

$ ./syslogd --foo
./syslogd: unrecognized option --foo'
Usage: syslogd [OPTION] ...
Try `syslogd --help' for more information.

$ ./syslogd --help
Usage: syslogd [OPTION] ...
Log system messages.

  -f, --rcfile=FILE  Override configuration file (default: 
/usr/local/etc/syslog.conf)
[...truncated...]
      --help         Display this help and exit
  -V, --version      Output version information and exit

Submit bug reports to <address@hidden>.

The GNU coding standard says to put a copyright notice in the --version
output, like ping does.  However, it should only contain the last year (the
year the package was released with this version).  So, proposed:

$ ./syslogd --version
syslogd (GNU inetutils) 1.3.2f
Copyright (C) 2001 Free Software Foundation, Inc.
GNU inetutils comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU inetutils
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

I am not particularly attached to the license wording, anything will do. 
The idea is, with that being in a header file or better in a library, it is
easily replaced for all programs.

I actually don't want to kick off a long discussion about the perfect style. 
Just that argp or another static lib is the way to go, and then I can hack
this in, and the details can be changed easily then for everyone.
How does this sound?

Thanks,
Marcus

-- 
`Rhubarb is no Egyptian god.' Debian http://www.debian.org address@hidden
Marcus Brinkmann              GNU    http://www.gnu.org    address@hidden
address@hidden
http://www.marcus-brinkmann.de



reply via email to

[Prev in Thread] Current Thread [Next in Thread]