#!/usr/bin/perl

use strict;

use lib '/var/lib/nocpulse/libexec';

use Getopt::Long;
use ProbeCatalog;

sub usage {
    print STDERR "Usage: $0 [--commandline|-c] [--dump|-d] [<probeid> [<probeid>...]]\n",
    "\tUse --commandline or -c to show the probe's Perl class and command line.\n",
    "\tUse --dump or -d to show the probe's database record.\n",
    "\tTo see individual probes, enter their IDs; otherwise you'll see all the probes ",
    "on the satellite.\n";
    exit 1;
}

my $catalog = new ProbeCatalog();

# Switches
my ($includeCommandLine, $dump, $help);

if (! GetOptions("commandline|c", \$includeCommandLine, "dump|d", \$dump, "help|h", \$help) || $help) {
    usage();
}

my @probes = @ARGV ? @ARGV : sort {$a <=> $b} $catalog->all_probes();

foreach my $probeid (@probes) {
    print $catalog->describe($probeid, $includeCommandLine, $dump)."\n";
}

__END__

=head1 NAME

    catalog - Show NOCpulse probe database contents

=head1 SYNOPSIS

    catalog [--commandline|-c] [--dump|-d] [<probeid> [<probeid>...]]


=head1 DESCRIPTION

This script shows the probe database record for the named probe, or all probes
if no probes are specified. The --commandline option shows the full command
line that will be used when the probe is run. The --dump option dumps the
probe database record along with the summary information.

=head1 AUTHOR

  Nick Hansen <nhansen@redhat.com>
