#!/usr/bin/perl -w
#========================================================================
#
# repo_init
#
# DESCRIPTION
#
#   Administrative tool for initializing a document 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: 2005/06/11 05:36:59 $
#
# $Id: repo_init,v 1.1.1.1 2005/06/11 05:36:59 bryce Exp $
#
# $Log: repo_init,v $
# Revision 1.1.1.1  2005/06/11 05:36:59  bryce
# Initial import
#
# Revision 1.2  2005/02/06 07:06:14  bryce
# Address change
#
# Revision 1.1  2004/08/15 22:39:34  bryce
# Adding some new commands to init a repository, put revisions of existing
# documents, and export documents from the repository.
#
#
#========================================================================

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

Getopt::Long::Configure ("bundling", "no_ignore_case");  
GetOptions(
           "help|h",             # Prints a brief help message
           "debug|D=i",          # Prints debug messages
            ) || pod2usage(1);

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

my $repository_dir = shift @ARGV;

pod2usage(-verbose => 1, -exitstatus => 0) unless $repository_dir;

if (-e $repository_dir) {
    die "Directory '$repository_dir' already exists.  Not overwriting.\n";
}

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

if (! $repo ) {
    die $repo->get_error();
} else {
    print "Created document repository '$repository_dir'\n";
}
    

exit 0;

__END__

=head1 NAME

repo_init - Administrative tool to establish a new document repository

=head1 SYNOPSIS

repo_init [options] repo_dir

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

=head1 DESCRIPTION

B<repo_init> - This is an administrative tool for creating a new
repository in a given directory.

Example:  `repo_init /var/dms`

The user executing this script must have direct read/write/execute
permisison into the directory where the document repository will be
placed.

To remove a document repository, simply `rm -rf` it.

=head1 AUTHOR

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

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

=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.1.1.1 $

=cut
