diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2005-08-17 08:32:30 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2005-08-17 08:32:30 +0000 |
commit | bfa2841b7e8ebb6e1b98816fbcf81bad1b85125e (patch) | |
tree | 302195e18073815a506cfda8a762fc995ec23ecd | |
parent | 3d0a72bae769774f5a665c9460940bf113d68507 (diff) |
document Getopt.
-rw-r--r-- | usr.sbin/pkg_add/Makefile | 3 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pod/OpenBSD::Getopt.pod | 29 |
2 files changed, 31 insertions, 1 deletions
diff --git a/usr.sbin/pkg_add/Makefile b/usr.sbin/pkg_add/Makefile index 36158e6585b..b81a4f7527a 100644 --- a/usr.sbin/pkg_add/Makefile +++ b/usr.sbin/pkg_add/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.27 2005/08/17 08:17:44 espie Exp $ +# $OpenBSD: Makefile,v 1.28 2005/08/17 08:32:28 espie Exp $ .include <bsd.own.mk> @@ -47,6 +47,7 @@ SCRIPTS= \ LIBBASE=/usr/libdata/perl5 PODS= \ + OpenBSD::Getopt \ OpenBSD::IdCache \ OpenBSD::Mtree \ OpenBSD::PackageName \ diff --git a/usr.sbin/pkg_add/pod/OpenBSD::Getopt.pod b/usr.sbin/pkg_add/pod/OpenBSD::Getopt.pod new file mode 100644 index 00000000000..a0d117b4626 --- /dev/null +++ b/usr.sbin/pkg_add/pod/OpenBSD::Getopt.pod @@ -0,0 +1,29 @@ +$OpenBSD: OpenBSD::Getopt.pod,v 1.1 2005/08/17 08:32:29 espie Exp $ + +=head1 NAME + +OpenBSD::Getopt - Process single-characters switches + +=head1 SYNOPSIS + + use OpenBSD::Getopt; + + our($opt_o, $opt_i, $opt_f, $opt_v); + getopts('oifv:', + { 'v' => sub { + ++$opt_v;} + } + +=head1 DESCRIPTION + +This is similar to L<getopt(3)>. One call to C<getopts($optstring)> parses +all the options using the C<$optstring> as a list of simple switches +(letter) and switches with arguments (letter followed by C<:>). + +Option values are directly written into local variables of the form +C<$opt_S>, where C<S> is the switch name. + +An optional hash can be used as a second argument, with switches as keys +and subs as values. When a switch is met, the sub C<$foo> is called as +C<$foo> for a simple switch and as C<$foo(option_value)> for a switch +with argument. |