#!/usr/bin/perl -w
#========================================================================
#
# repo_add
#
# DESCRIPTION
#
#   Administrative tool for directly adding a document to the repository
#   managed by Document::Repository.
#
# AUTHOR
#   Bryce W. Harrington <bryce at bryceharrington dot com>
#
# COPYRIGHT
#   Copyright (C) 2004 Bryce W. Harrington  
#   All Rights Reserved.
#
#   This module is free software; you can redistribute it and/or
#   modify it under the same terms as Perl itself.
#
#------------------------------------------------------------------------
#
# Last Modified:  $Date: $
#
# $Id: $
#
# $Log: $
#========================================================================

use strict;                             # Forces variable decl's
use Carp;                               # Improved error/warning prints
use Pod::Usage;                         # To report program usage
use Getopt::Long;                       # Basic cmdline arg handling
use Document::Repository;

#------------------------------------------------------------------------
# Commandline option processing
#------------------------------------------------------------------------

our $opt_help            = 0;    # Prints a brief help message
our $opt_debug           = 0;    # Prints debug messages
our $opt_repository_dir  = '';   # Location of the repository

Getopt::Long::Configure ("bundling");  
GetOptions(
           "help|h",             # Prints a brief help message
           "debug|D=i",          # Prints debug messages
	   "repository_dir|d=s", # Location of the repository
            ) || pod2usage(1);

pod2usage(-verbose => 1, -exitstatus => 0) if $opt_help;

my $repo = new Document::Repository( repository_dir => $opt_repository_dir,
				     debug          => $opt_debug );

my $doc_id = $repo->add(@ARGV);
if (! $doc_id ) {
    die $repo->get_error();
} else {
    print "Created document id '$doc_id'\n";
}
    

exit 0;

__END__

=head1 NAME

repo_add - Administrative tool to directly add a document to a document
repository.

=head1 SYNOPSIS

repo_add [options] filename [ filename [...] ]

 Options:
   -h, --help                    Prints a brief help message
   -D, --debug=integer           Prints debug messages

=head1 DESCRIPTION

B<repo_add> - This is an administrative tool that directly accesses a
document repository via the Document::Repository module.  It creates a
new document from the set of files specified on the commandline.  Note 
that all files are added as a single document.

The user executing this script must have direct read/write/execute
permisison into the document repository.

=head1 AUTHOR

Bryce W. Harrington E<lt>bryce at bryceharrington dot comE<gt>

L<http://www.bryceharrington.com>

=head1 COPYRIGHT

Copyright (C) 2004 Bryce W. Harrington.
All Rights Reserved.

This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.

=head1 REVISION

Revision: $Revision: 1.2 $

=cut



