AFS-Command
view release on metacpan or search on metacpan
lib/AFS/Command/Base.pod view on Meta::CPAN
syslog may be a more appropriate destination. In this case, the
setCarp method may be used to configure this, globally, for the entire
API.
AFS::Command->setCarp
(
carp => sub {
my ($lines) = @_;
foreach my $line ( split(/\n+/,$lines) ) {
syslog('warning',$line);
}
},
croak => sub {
my ($lines) = @_;
foreach my $line ( split(/\n+/,$lines) ) {
syslog('error',$line);
}
die $lines; # If we're dying, whine at stderr, too.
},
);
This method takes a list of key/value pairs, with only two supported
keys (anything else will be quietly ignored): carp an croak. The
values are CODE references (anonymous subroutines, or references to
existing subroutines). The carp CODE should not be fatal, however the
croak CODE should. The API calls the croak method in very few places,
but when it does, it assumes that call will be fatal, so if you
provide a croak subroutine that doesn't die, the results will be
unpredictable, and unsupportable.
This method returns true of false, depending on whether or not the
carp and/or croak subroutines were properly configured. If the values
are not CODE references, then this method will itself croak.
=head1 INSTANCE METHODS
=head2 errors
This method takes no arguments, and it returns a string, containing the
unparsed errors from the last command method invoked. This string is
reset with each subsequent command method invocation. The string is
normally the output written to stderr by the process, but in the case
of unparsed boolean commands, it contains both the stdout as well as
the stderr output.
my $result = $vos->examine
(
id => $volname,
cell => $cell,
);
unless ( $result ) {
die "Unable to examine volname '$volname' in cell '$cell':" .
$vos->errors();
}
=head2 supportsOperation
This class method allows the developer to test whether or not any
given operation is supported by the underlying command line utility.
For example, the "vos changeloc" operation is not supported in older
release of vos.
unless ( $vos->supportsOperation('changeloc') {
die "Unable to continue -- 'vos changeloc' is unsupported.\n";
}
The return value is simply true or false.
=head2 supportsArgument
Similar to supportsOperation, supportsArgument will test whether or
not a given argument is a support command line argument for the
specified operation. For example, the -encrypt argument is only
supported in more recent versions of vos, so that support can be
tested for easily.
unless ( $vos->supportsArgument('listvldb','encrypt') ) {
warn "Encryption is not support by your version of vos.\n";
}
The return value is simply true or false.
=head1 SEE ALSO
AFS::Command::VOS(1), AFS::Command::BOS(1), AFS::Command::PTS(1),
AFS::Command::FS(1), AFS::Command::Base(1), AFS::Command(1)
=cut
( run in 0.306 second using v1.01-cache-2.11-cpan-39bf76dae61 )