#! /usr/bin/perl -w

# vim:syntax=perl

use strict;

use lib '/usr/share/perl5';

use Lire::Program qw( :msg $PROG );
use Lire::PluginManager;

lr_err( "Usage: $PROG <service>|-l" ) unless @ARGV == 1;

Lire::PluginManager->register_default_plugins();

if ($ARGV[0] eq '-l') {
    print join( "\n", @{ Lire::PluginManager->plugin_names( 'dlf_converter' )} ), "\n";
    exit 0;
} else {
    if (  Lire::PluginManager->has_plugin( 'dlf_converter', $ARGV[0] ) ) {
        print Lire::PluginManager->get_plugin( 'dlf_converter', $ARGV[0] )->name(), "\n";
    } else {
        lr_err( <<EOF );
'$ARGV[0]' isn't a known DLF converter.
Use lr_check_service -l to obtain the list of available converters.
EOF
    }
}

exit 0;

__END__

=pod

=head1 NAME

lr_check_service - check existence of Lire service

=head1 SYNOPSIS

B<lr_check_service> I<service>

B<lr_check_service> B<-l>

=head1 DESCRIPTION

B<lr_check_service> checks if service I<service> is supported in Lire,
i.e. if there is a DLF converter registered under that name.

When called with the B<-l> (for `list') option, B<lr_check_service> lists all
registered DLF converters.

Like all Lire scripts, you might want to call this script via lr_run(1), to
deal sanely with this scripts' debug- and logging output.

You might prefer the lr_log2report(1) --help options to list available
services: this command creates a more human-friendly format of the list.

=head1 EXAMPLE

Call this script in shell scripts as

 LR_SERVICE="$1"

 LR_SERVICE=`lr_check_service "$LR_SERVICE" || true`
 if test -z "$LR_SERVICE"
 then
    echo >&2 "$tag err lr_check_service failed"
    exit 1
 fi

 # now go using $LR_SERVICE

.

=head1 SEE ALSO

Lire::PluginManager(3pm), lr_log2report(1)

=head1 VERSION

$Id: lr_check_service.in,v 1.13 2006/07/23 13:16:32 vanbaal Exp $

=head1 COPYRIGHT

Copyright (C) 2002-2003 Stichting LogReport Foundation LogReport@LogReport.org

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program (see COPYING); if not, check with
http://www.gnu.org/copyleft/gpl.html. 

=head1 AUTHOR

Joost van Baal <joostvb@logreport.org>

=cut

# Local Variables:
# mode: cperl
# End:

