AC_PREREQ(2.53)
-AC_REVISION($Header: /cvsroot/autodoc/autodoc/Attic/configure.ac,v 1.1 2004/05/12 16:00:34 rbt Exp $)
+AC_REVISION($Header: /cvsroot/autodoc/autodoc/Attic/configure.ac,v 1.2 2007/01/02 13:53:19 rbt Exp $)
AC_INIT(postgresql_autodoc.pl)
# DBD::Pg
# Fcntl
# HTML::Template
+# Term::ReadKey
#
# Output of if test redirected to /dev/null to keep quiet
-for module in DBI DBD::Pg Fcntl HTML::Template ; do
+for module in DBI DBD::Pg Fcntl HTML::Template Term::ReadKey ; do
AC_MSG_CHECKING(${module})
if [ ! (${PERL} -e "use ${module}" 2>&1 /dev/null ) ]; then
AC_MSG_RESULT(no)
#!/usr/bin/env perl
# -- # -*- Perl -*-w
-# $Header: /cvsroot/autodoc/autodoc/postgresql_autodoc.pl,v 1.14 2006/05/16 19:01:27 rbt Exp $
+# $Header: /cvsroot/autodoc/autodoc/postgresql_autodoc.pl,v 1.15 2007/01/02 13:53:19 rbt Exp $
# Imported 1.22 2002/02/08 17:09:48 into sourceforge
# Postgres Auto-Doc Version 1.30
# License
# -------
-# Copyright (c) 2001-2005, Rod Taylor
+# Copyright (c) 2001-2007, Rod Taylor
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# Allows file templates
use HTML::Template;
+# Allow reading a password from stdin
+use Term::ReadKey;
+
sub main($)
{
my ($ARGV) = @_;
my $dbport = $ENV{'PGPORT'};
$dbport ||= "";
+ # Determine whether we need a password to connect
+ my $needpass = 0;
+
my $dbpass = "";
my $output_filename_base = $database;
last;
};
+ # Make sure we get a password before attempting to conenct
+ /^--password$/ && do {
+ $needpass = 1;
+ last;
+ };
+
# Set the base of the filename. The extensions pulled
# from the templates will be appended to this name
/^-f$/ && do {
;
}
+ # If needpass has been set but no password was provided, prompt the user
+ # for a password.
+ if ($needpass and not $dbpass) {
+ print "Password: ";
+ ReadMode 'noecho';
+ $dbpass = ReadLine 0;
+ chomp $dbpass;
+ ReadMode 'normal';
+ print "\n";
+ }
+
# Database Connection
my $dsn = "dbi:Pg:dbname=$database";
$dsn .= ";host=$dbhost" if ( "$dbhost" ne "" );
-p <port> Specify database server port (default: 5432)
-u <username> Specify database username (default: $dbuser)
--password=<pw> Specify database password (default: blank)
+ --password Have $basename prompt for a password
-l <path> Path to the templates (default: @@TEMPLATE-DIR@@)
-t <output> Type of output wanted (default: All in template library)