diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2003-02-08 08:45:35 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2003-02-08 08:45:35 +0000 |
commit | 5fc0f0f6e90f423ffa278e3f31f7021206604ee9 (patch) | |
tree | 5b2e1c273398658ee95394052bd8fd53b1c2f75e /lib/CPAN/FirstTime.pm | |
parent | 9c36735de2bc373cab0c4275429b13fc1c754d20 (diff) | |
download | perl-5fc0f0f6e90f423ffa278e3f31f7021206604ee9.tar.gz |
Upgrade to CPAN 1.64, from Andreas Koenig.
p4raw-id: //depot/perl@18672
Diffstat (limited to 'lib/CPAN/FirstTime.pm')
-rw-r--r-- | lib/CPAN/FirstTime.pm | 95 |
1 files changed, 67 insertions, 28 deletions
diff --git a/lib/CPAN/FirstTime.pm b/lib/CPAN/FirstTime.pm index 578a5bd6e5..8a1724a3a2 100644 --- a/lib/CPAN/FirstTime.pm +++ b/lib/CPAN/FirstTime.pm @@ -18,7 +18,7 @@ use File::Basename (); use File::Path (); use File::Spec; use vars qw($VERSION); -$VERSION = substr q$Revision: 1.56 $, 10; +$VERSION = substr q$Revision: 1.58 $, 10; =head1 NAME @@ -48,7 +48,7 @@ sub init { local($\) = ""; local($|) = 1; - my($ans,$default,$local,$cont,$url,$expected_size); + my($ans,$default); # # Files, directories @@ -117,6 +117,14 @@ First of all, I\'d like to create this directory. Where? $default = $cpan_home; while ($ans = prompt("CPAN build and cache directory?",$default)) { + unless (File::Spec->file_name_is_absolute($ans)) { + require Cwd; + my $cwd = Cwd::cwd(); + my $absans = File::Spec->catdir($cwd,$ans); + warn "The path '$ans' is not an absolute path. Please specify an absolute path\n"; + $default = $absans; + next; + } eval { File::Path::mkpath($ans); }; # dies if it can't if ($@) { warn "Couldn't create directory $ans. @@ -218,6 +226,32 @@ will be output in UTF-8. $CPAN::Config->{term_is_latin} = ($ans =~ /^\s*y/i ? 1 : 0); # + # save history in file histfile + # + print qq{ + +If you have one of the readline packages (Term::ReadLine::Perl, +Term::ReadLine::Gnu, possibly others) installed, the interactive CPAN +shell will have history support. The next two questions deal with the +filename of the history file and with its size. If you do not want to +set this variable, please hit SPACE RETURN to the following question. + +}; + + defined($default = $CPAN::Config->{histfile}) or + $default = File::Spec->catfile($CPAN::Config->{cpan_home},"histfile"); + $ans = prompt("File to save your history?", $default); + $ans =~ s/^\s+//; + $ans =~ s/\s+\z//; + $CPAN::Config->{histfile} = $ans; + + if ($CPAN::Config->{histfile}) { + defined($default = $CPAN::Config->{histsize}) or $default = 100; + $ans = prompt("Number of lines to save?", $default); + $CPAN::Config->{histsize} = $ans; + } + + # # prerequisites_policy # Do we follow PREREQ_PM? # @@ -519,33 +553,33 @@ sub picklist { my($items,$prompt,$default,$require_nonempty,$empty_warning)=@_; $default ||= ''; - my $pos = 0; + my $pos = 0; my @nums; while (1) { - # display, at most, 15 items at a time - my $limit = $#{ $items } - $pos; - $limit = 15 if $limit > 15; - - # show the next $limit items, get the new position - $pos = display_some($items, $limit, $pos); - $pos = 0 if $pos >= @$items; - - my $num = prompt($prompt,$default); - - @nums = split (' ', $num); - my $i = scalar @$items; - (warn "invalid items entered, try again\n"), next - if grep (/\D/ || $_ < 1 || $_ > $i, @nums); - if ($require_nonempty) { - (warn "$empty_warning\n"); - } - print "\n"; - - # a blank line continues... - next unless @nums; - last; + # display, at most, 15 items at a time + my $limit = $#{ $items } - $pos; + $limit = 15 if $limit > 15; + + # show the next $limit items, get the new position + $pos = display_some($items, $limit, $pos); + $pos = 0 if $pos >= @$items; + + my $num = prompt($prompt,$default); + + @nums = split (' ', $num); + my $i = scalar @$items; + (warn "invalid items entered, try again\n"), next + if grep (/\D/ || $_ < 1 || $_ > $i, @nums); + if ($require_nonempty) { + (warn "$empty_warning\n"); + } + print "\n"; + + # a blank line continues... + next unless @nums; + last; } for (@nums) { $_-- } @{$items}[@nums]; @@ -559,7 +593,10 @@ sub display_some { for my $item (@displayable) { printf "(%d) %s\n", ++$pos, $item; } - printf "%d more items, hit ENTER\n", (@$items - $pos) if $pos < @$items; + printf("%d more items, hit SPACE RETURN to show them\n", + (@$items - $pos) + ) + if $pos < @$items; return $pos; } @@ -643,8 +680,8 @@ http: -- that host a CPAN mirror. } } push (@urls, map ("$_ (previous pick)", @previous_urls)); - my $prompt = "Select as many URLs as you like, -put them on one line, separated by blanks"; + my $prompt = "Select as many URLs as you like (by number), +put them on one line, separated by blanks, e.g. '1 4 5'"; if (@previous_urls) { $default = join (' ', ((scalar @urls) - (scalar @previous_urls) + 1) .. (scalar @urls)); @@ -669,6 +706,8 @@ Please enter your CPAN site:}; $ans = prompt ($prompt, ""); if ($ans) { + $ans =~ s/^\s+//; # no leading spaces + $ans =~ s/\s+\z//; # no trailing spaces $ans =~ s|/?\z|/|; # has to end with one slash $ans = "file:$ans" unless $ans =~ /:/; # without a scheme is a file: if ($ans =~ /^\w+:\/./) { |