summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/OpenBSD
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2004-12-06 12:35:37 +0000
committerMarc Espie <espie@cvs.openbsd.org>2004-12-06 12:35:37 +0000
commit5bdb7a1f65ec91239613dfe6c0e7daae9204af1e (patch)
tree40fde354c2c6cc5e036daf7be2a54ca311c71142 /usr.sbin/pkg_add/OpenBSD
parentb528e2efc28e96840ad933398c9d8802737b97a0 (diff)
Usage
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Error.pm26
1 files changed, 24 insertions, 2 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Error.pm b/usr.sbin/pkg_add/OpenBSD/Error.pm
index 7498bb35865..daffc2e52c9 100644
--- a/usr.sbin/pkg_add/OpenBSD/Error.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Error.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Error.pm,v 1.7 2004/11/27 12:07:58 espie Exp $
+# $OpenBSD: Error.pm,v 1.8 2004/12/06 12:35:36 espie Exp $
#
# Copyright (c) 2004 Marc Espie <espie@openbsd.org>
#
@@ -20,7 +20,7 @@ use warnings;
package OpenBSD::Error;
our @ISA=qw(Exporter);
-our @EXPORT=qw(System VSystem Copy Fatal Warn);
+our @EXPORT=qw(System VSystem Copy Fatal Warn Usage set_usage);
sub System
{
@@ -131,4 +131,26 @@ sub system
$state->print("system(", join(", ", @_), ") was not run: $! $?\n");
}
}
+
+my @usage_line;
+
+sub set_usage
+{
+ @usage_line = @_;
+}
+
+sub Usage
+{
+ my $code = 0;
+ if (@_) {
+ print STDERR "Error: ", @_, "\n";
+ $code = 1;
+ }
+ print STDERR "Usage: ", shift(@usage_line), "\n";
+ for my $l (@usage_line) {
+ print STDERR " $l\n";
+ }
+ exit($code);
+}
+
1;