#! /usr/bin/env perl

# $Id: detDSFetch 169 2007-03-08 02:16:06Z yamada $

#use lib '/home/yamada/prj/panstarrs/mops/src';

use warnings;
use strict;
use Getopt::Long;
use Pod::Usage;

use PS::MOPS::DET::htclient;

my $help;
my $datastore = $ENV{'MOPS_DATASTORE'};
my $instance_name = $ENV{'MOPS_DBINSTANCE'};

GetOptions(
	'datastore=s' => \$datastore,
	'instance=s' => \$instance_name,
    help => \$help,
) or pod2usage(2);                      # opts parse error
pod2usage(-verbose => 3) if $help;      # user asked for help
die("Must specify instance name or MOPS_DBINSTANCE") unless $instance_name;
die("Must specify data store or MOPS_DATASTORE") unless $datastore;
die("Must specify at least one file") unless @ARGV;

my $server_url = "http://$datastore/";

for my $filename ( @ARGV ) {
	PS::MOPS::DET::htclient::file_remove($server_url, $instance_name,
		$filename);
}

__END__

=head1 NAME

detDSRemove - Remove a file from the data store.

=head1 SYNOPSIS

detDSRemove [OPTIONS] DBFILE [DBFILE [...]

=head1 OPTIONS

=over 4

=item --instance=INSTANCE

Instance name.  Either the --instance option or the MOPS_DBINSTANCE 
environment variable must be used.  If both are used, the command line
option has priority.

=item --datastore=HOSTNAME[:PORT]

Data store server name.  If the server is listening on a non-standard
port, the port may be specified also.  Either the --datastore option
or the MOPS_DATASTORE environment variable must be used.  If both
are used, the command line option has priority.

=back

=head1 ARGUMENTS

=over 4

=item DBFILE

Data store file name.

=back

=head1 DESCRIPTION

Removes a detections file from the data store.

=head1 ENVIRONMENT VARIABLES

=over 4

=item MOPS_DBINSTANCE

Simulation instance.

=item MOPS_DATASTORE

Hostname or hostname:port used to specify the data store.

=back

=head1 TO DO

=head1 BUGS

=cut
