Catalog
view release on metacpan or search on metacpan
conf/lib.pl view on Meta::CPAN
#
# Copyright (C) 1998, 1999 Loic Dachary
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
# $Header: /cvsroot/Catalog/Catalog/conf/lib.pl,v 1.3 1999/09/07 14:48:03 loic Exp $
#
#
# Perl module configuration utility functions
#
# Parameters in *all* configurations files must be unique.
# If parameter set by environment variable, don't go to interactive mode
# If parameter set by environment variable but checking says it's wrong
# go to interactive mode
# If USE_DEFAULTS set to 1 only go to interactive mode if checking says
# that a parameter is wrong
# Providing a directory containing an existing configuration with USE_CONFIG
# or interactively automatically set USE_DEFAULTS.
#
# Usage:
# in a Makefile.PL
#
# require "lib.pl"
# #
# # Mapping between configuration label and environment variables
# #
# conf_env(
# 'infodir' => 'INFODIR',
# 'cgidir' => 'CGIDIR',
# 'cgipath' => 'CGIPATH',
# 'config_dir' => 'CONFIG_DIR',
# 'use_config' => 'USE_CONFIG',
# 'htmldir' => 'HTMLDIR',
# 'htmlpath' => 'HTMLPATH',
# 'userid' => 'USERID',
# 'home' => 'MYSQL_HOME',
# 'user' => 'MYSQL_USER',
# 'passwd' => 'MYSQL_PASSWORD',
# 'host' => 'MYSQL_HOST',
# 'base' => 'MYSQL_BASE',
# 'port' => 'MYSQL_PORT',
# 'unix_port' => 'MYSQL_UNIX_PORT',
# );
# #
# # Get configuration parameters
# #
# sub install_ask {
# my($install_conf) = load_config("install.conf");
#
# getparam('cgidir', $install_conf,
# {
# 'prompt' => "
#The absolute pathname of the directory where the cgi-bin
#scripts will be installed",
# 'mandatory' => 1,
# 'directory' => 1,
# 'absolute' => 1,
# });
#
# yesno('html', \%h,
# {
# 'prompt' => "
#Do you you want HTML formated documentation ? ",
# 'yesno' => 1,
# 'default' => exists($ENV{'DOC_HTML'}) ? $ENV{'DOC_HTML'} : 'yes',
# });
#
# unload_config($install_conf, "install.conf");
# }
# #
# # Possible re-use of an existing configuration
# #
# search_conf();
# #
# # Effective configuration
# #
# install_ask();
#
use strict;
%::var2env = (
'use_config' => 'USE_CONFIG',
);
#
# Add more mapping between configuration variables and environment variables
#
sub conf_env {
my(%conf) = @_;
%::var2env = ( %::var2env, %conf );
%::env2var = map { $::var2env{$_} => $_ } keys(%::var2env);
}
#
# Set $h->{$var} to the value provided by the user
# $spec
# (see $spec of getparam_valid for more)
# prompt : prompt shown to user
#
# Uses $::var2env to find the environment variable overriding $var value
#
# If parameter set by environment variable, don't go to interactive mode
# If parameter set by environment variable but checking says it's wrong
# go to interactive mode
# If USE_DEFAULTS set to 1 only go to interactive mode if checking says
# that a parameter is wrong
#
sub getparam {
( run in 2.157 seconds using v1.01-cache-2.11-cpan-5735350b133 )