[Module::Build] stem config code
Status: Beta
Brought to you by:
kwilliams
|
From: Uri G. <ur...@st...> - 2004-01-04 07:02:44
|
well, i think i got it all working now. it isn't too bad. i even added
in the edited prompt when the default is very long thingy.
here is the relevant code:
my %defaults = (
bin_path => $Config{bin},
perl_path => $Config{perlpath},
conf_path => $default_conf_path,
prefix => $Config{prefix},
tail_dir => $default_tail_dir,
install_stem_demos => $is_win32,
install_ssfe => $is_win32,
%Stem::InstallConfig::Config,
);
sub query_config_value {
my( $self, $query, $key ) = @_ ;
my $default = $self->{args}{$key} ;
$default = $defaults{ $key } unless defined $default ;
$defaults{ $key } = ( $self->{args}{use_defaults} ) ?
$default :
$self->prompt( edit_query( $query, $default ), $default ) ;
}
sub get_config_boolean {
my( $self, $query, $key ) = @_ ;
my $default = $self->{args}{$key} ;
$default = $defaults{ $key } unless defined $default ;
$default = $default ? 'y' : 'n' ;
$defaults{ $key } = ( $self->{args}{use_defaults} ) ?
$default :
$self->y_n( edit_query( $query, $default ), $default ) ;
}
sub edit_query {
my ( $query, $default ) = @_ ;
chomp $query ;
my $last_line = (split /\n/, $query)[-1] ;
if ( length( $last_line ) + 2 * length( $default ) > 70 ) {
$query .= "\n\t" ;
}
return $query ;
}
note that i found a little problem with the boolean/y_n query. the
%defaults value is 1/0 (also from the loaded config hash) and that is
the result is also 1/0. but the default in the prompt has to be y/n. so
i had to make a conversion to y/n before the actual query. since the y_n
method knows it will be either y/n it should handle this for you. the
y_n method passes @_ to the prompt method so that would need changing to
store the args so the default can be forced to y/n and passed to
prompt().
now onto the actual install work which is mostly done and needs cleaning
up and testing.
uri
--
Uri Guttman ------ ur...@st... -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
|