| 1 | package CPANPLUS::Shell; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use CPANPLUS::Error; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use CPANPLUS::Configure; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use CPANPLUS::Internals::Constants; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Module::Load qw[load]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Params::Check qw[check]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Locale::Maketext::Simple Class => 'CPANPLUS', Style => 'gettext'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 1 | $Params::Check::VERBOSE = 1; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use vars qw[@ISA $SHELL $DEFAULT $VERSION]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 1 | $VERSION = "0.9912"; | |||||||||||||||||||||||||||
| 18 | 1 | $DEFAULT = SHELL_DEFAULT; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | =pod | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | =head1 NAME | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | CPANPLUS::Shell - base class for CPANPLUS shells | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | use CPANPLUS::Shell; # load the shell indicated by your | ||||||||||||||||||||||||||||
| 29 | # config -- defaults to | ||||||||||||||||||||||||||||
| 30 | # CPANPLUS::Shell::Default | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | use CPANPLUS::Shell qw[Classic] # load CPANPLUS::Shell::Classic; | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | my $ui = CPANPLUS::Shell->new(); | ||||||||||||||||||||||||||||
| 35 | my $name = $ui->which; # Find out what shell you loaded | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | $ui->shell; # run the ui shell | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | This module is the generic loading (and base class) for all C<CPANPLUS> | ||||||||||||||||||||||||||||
| 43 | shells. Through this module you can load any installed C<CPANPLUS> | ||||||||||||||||||||||||||||
| 44 | shell. | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | Just about all the functionality is provided by the shell that you have | ||||||||||||||||||||||||||||
| 47 | loaded, and not by this class (which merely functions as a generic | ||||||||||||||||||||||||||||
| 48 | loading class), so please consult the documentation of your shell of | ||||||||||||||||||||||||||||
| 49 | choice. | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | =cut | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | sub import { | ||||||||||||||||||||||||||||
| 54 | 1 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
import: called CC=6 SCAR=26.2
| |||||||||||||||||||||||||||||
| 55 | 1 | my $option = shift; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | ### find out what shell we're supposed to load ### | ||||||||||||||||||||||||||||
| 58 | $SHELL = $option | ||||||||||||||||||||||||||||
| 59 | ? $class . '::' . $option | ||||||||||||||||||||||||||||
| 60 | 1 | ▶ | : do { ### XXX this should offer to reconfigure | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | ### CPANPLUS, somehow. --rs | ||||||||||||||||||||||||||||
| 62 | ### XXX load Configure only if we really have to | ||||||||||||||||||||||||||||
| 63 | ### as that means any $Conf passed later on will | ||||||||||||||||||||||||||||
| 64 | ### be ignored in favour of the one that was | ||||||||||||||||||||||||||||
| 65 | ### retrieved via ->new --kane | ||||||||||||||||||||||||||||
| 66 | 0 | ▶ | my $conf = CPANPLUS::Configure->new() or | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | die loc("No configuration available -- aborting") . $/; | ||||||||||||||||||||||||||||
| 68 | 0 | ▶ | $conf->get_conf('shell') || $DEFAULT; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | }; | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | ### load the shell, fall back to the default if required | ||||||||||||||||||||||||||||
| 72 | ### and die if even that doesn't work | ||||||||||||||||||||||||||||
| 73 | EVAL: { | ||||||||||||||||||||||||||||
| 74 | 1 | eval { load $SHELL }; | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 1 | ▶ | if( $@ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | 0 | my $err = $@; | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | ▶ | die loc("Your default shell '%1' is not available: %2", | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | $DEFAULT, $err) . | ||||||||||||||||||||||||||||
| 81 | loc("Check your installation!") . "\n" | ||||||||||||||||||||||||||||
| 82 | if $SHELL eq $DEFAULT; | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 0 | warn loc("Failed to use '%1': %2", $SHELL, $err), | |||||||||||||||||||||||||||
| 85 | loc("Switching back to the default shell '%1'", $DEFAULT), | ||||||||||||||||||||||||||||
| 86 | "\n"; | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 0 | $SHELL = $DEFAULT; | |||||||||||||||||||||||||||
| 89 | 0 | redo EVAL; | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | 1 | @ISA = ($SHELL); | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 0 | ▶ | sub which { return $SHELL } | ||||||||||||||||||||||||||
|
Subroutine
which: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 1 | 1; | |||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | ########################################################################### | ||||||||||||||||||||||||||||
| 100 | ### abstracted out subroutines available to programmers of other shells ### | ||||||||||||||||||||||||||||
| 101 | ########################################################################### | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | package CPANPLUS::Shell::_Base::ReadLine; | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 106 | 1 | ▶ | use vars qw($AUTOLOAD $TMPL); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 1 | ▶ | use FileHandle; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 109 | 1 | ▶ | use CPANPLUS::Error; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 110 | 1 | ▶ | use Params::Check qw[check]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 111 | 1 | ▶ | use Module::Load::Conditional qw[can_load]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 112 | 1 | ▶ | use Locale::Maketext::Simple Class => 'CPANPLUS', Style => 'gettext'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 1 | $Params::Check::VERBOSE = 1; | |||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 1 | $TMPL = { | |||||||||||||||||||||||||||
| 118 | brand => { default => '', strict_type => 1 }, | ||||||||||||||||||||||||||||
| 119 | prompt => { default => '> ', strict_type => 1 }, | ||||||||||||||||||||||||||||
| 120 | pager => { default => '' }, | ||||||||||||||||||||||||||||
| 121 | backend => { default => '' }, | ||||||||||||||||||||||||||||
| 122 | term => { default => '' }, | ||||||||||||||||||||||||||||
| 123 | format => { default => '' }, | ||||||||||||||||||||||||||||
| 124 | dist_format => { default => '' }, | ||||||||||||||||||||||||||||
| 125 | remote => { default => undef }, | ||||||||||||||||||||||||||||
| 126 | noninteractive => { default => '' }, | ||||||||||||||||||||||||||||
| 127 | cache => { default => [ ] }, | ||||||||||||||||||||||||||||
| 128 | settings => { default => { install_all_prereqs => undef }, | ||||||||||||||||||||||||||||
| 129 | no_override => 1 }, | ||||||||||||||||||||||||||||
| 130 | _old_sigpipe => { default => '', no_override => 1 }, | ||||||||||||||||||||||||||||
| 131 | _old_outfh => { default => '', no_override => 1 }, | ||||||||||||||||||||||||||||
| 132 | _signals => { default => { INT => { } }, no_override => 1 }, | ||||||||||||||||||||||||||||
| 133 | }; | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | ### autogenerate accessors ### | ||||||||||||||||||||||||||||
| 136 | 1 | for my $key ( keys %$TMPL ) { | |||||||||||||||||||||||||||
| 137 | 1 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 138 | 14 | *{__PACKAGE__."::$key"} = sub { | |||||||||||||||||||||||||||
| 139 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 140 | 0 | ▶ | $self->{$key} = $_[0] if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 141 | 0 | return $self->{$key}; | |||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | 14 | } | |||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | sub _init { | ||||||||||||||||||||||||||||
| 146 | 0 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
_init: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 147 | 0 | my %hash = @_; | |||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 0 | ▶ | my $self = check( $TMPL, \%hash ) or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | 0 | bless $self, $class; | |||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | ### signal handler ### | ||||||||||||||||||||||||||||
| 154 | $SIG{INT} = $self->_signals->{INT}->{handler} = | ||||||||||||||||||||||||||||
| 155 | sub { | ||||||||||||||||||||||||||||
| 156 | 0 | ▶ | unless ( $self->_signals->{INT}->{count}++ ) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 157 | 0 | warn loc("Caught SIGINT"), "\n"; | |||||||||||||||||||||||||||
| 158 | } else { | ||||||||||||||||||||||||||||
| 159 | 0 | warn loc("Got another SIGINT"), "\n"; die; | |||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||
| 161 | 0 | }; | |||||||||||||||||||||||||||
| 162 | ### end sig handler ### | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 0 | return $self; | |||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | ### display shell's banner, takes the Backend object as argument | ||||||||||||||||||||||||||||
| 168 | sub _show_banner { | ||||||||||||||||||||||||||||
| 169 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_show_banner: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||
| 170 | 0 | my $cpan = $self->backend; | |||||||||||||||||||||||||||
| 171 | 0 | my $term = $self->term; | |||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | ### Tries to probe for our ReadLine support status | ||||||||||||||||||||||||||||
| 174 | # a) under an interactive shell? | ||||||||||||||||||||||||||||
| 175 | 0 | ▶ | my $rl_avail = (!$term->isa('CPANPLUS::Shell::_Faked')) | ||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||
| 176 | # b) do we have a tty terminal? | ||||||||||||||||||||||||||||
| 177 | ? (-t STDIN) | ||||||||||||||||||||||||||||
| 178 | # c) should we enable the term? | ||||||||||||||||||||||||||||
| 179 | ? (!$self->__is_bad_terminal($term)) | ||||||||||||||||||||||||||||
| 180 | # d) external modules available? | ||||||||||||||||||||||||||||
| 181 | ? ($term->ReadLine ne "Term::ReadLine::Stub") | ||||||||||||||||||||||||||||
| 182 | # a+b+c+d => "Smart" terminal | ||||||||||||||||||||||||||||
| 183 | ? loc("enabled") | ||||||||||||||||||||||||||||
| 184 | # a+b+c => "Stub" terminal | ||||||||||||||||||||||||||||
| 185 | : loc("available (try 'i Term::ReadLine::Perl')") | ||||||||||||||||||||||||||||
| 186 | # a+b => "Bad" terminal | ||||||||||||||||||||||||||||
| 187 | : loc("disabled") | ||||||||||||||||||||||||||||
| 188 | # a => "Dumb" terminal | ||||||||||||||||||||||||||||
| 189 | : loc("suppressed") | ||||||||||||||||||||||||||||
| 190 | # none => "Faked" terminal | ||||||||||||||||||||||||||||
| 191 | : loc("suppressed in batch mode"); | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | 0 | $rl_avail = loc("ReadLine support %1.", $rl_avail); | |||||||||||||||||||||||||||
| 194 | 0 | ▶ | $rl_avail = "\n*** $rl_avail" if (length($rl_avail) > 45); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | 0 | $self->__print( | |||||||||||||||||||||||||||
| 197 | loc("%1 -- CPAN exploration and module installation (v%2)", | ||||||||||||||||||||||||||||
| 198 | $self->which, $self->which->VERSION()), "\n", | ||||||||||||||||||||||||||||
| 199 | loc("*** Please report bugs to <bug-cpanplus\@rt.cpan.org>."), "\n", | ||||||||||||||||||||||||||||
| 200 | loc("*** Using CPANPLUS::Backend v%1. %2", | ||||||||||||||||||||||||||||
| 201 | $cpan->VERSION, $rl_avail), "\n\n" | ||||||||||||||||||||||||||||
| 202 | ); | ||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | ### checks whether the Term::ReadLine is broken and needs to fallback to Stub | ||||||||||||||||||||||||||||
| 206 | sub __is_bad_terminal { | ||||||||||||||||||||||||||||
| 207 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
__is_bad_terminal: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 208 | 0 | my $term = $self->term; | |||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | 0 | ▶ | return unless $^O eq 'MSWin32'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | ### replace the term with the default (stub) one | ||||||||||||||||||||||||||||
| 213 | 0 | return $self->term(Term::ReadLine::Stub->new( $self->brand ) ); | |||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | ### open a pager handle | ||||||||||||||||||||||||||||
| 217 | sub _pager_open { | ||||||||||||||||||||||||||||
| 218 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_pager_open: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 219 | 0 | my $cpan = $self->backend; | |||||||||||||||||||||||||||
| 220 | 0 | ▶ | my $cmd = $cpan->configure_object->get_program('pager') or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 0 | $self->_old_sigpipe( $SIG{PIPE} ); | |||||||||||||||||||||||||||
| 223 | 0 | $SIG{PIPE} = 'IGNORE'; | |||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | 0 | my $fh = new FileHandle; | |||||||||||||||||||||||||||
| 226 | 0 | ▶ | unless ( $fh->open("| $cmd") ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 227 | 0 | error(loc("could not pipe to %1: %2\n", $cmd, $!) ); | |||||||||||||||||||||||||||
| 228 | 0 | return; | |||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | 0 | $fh->autoflush(1); | |||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | 0 | $self->pager( $fh ); | |||||||||||||||||||||||||||
| 234 | 0 | $self->_old_outfh( select $fh ); | |||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | 0 | return $fh; | |||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | ### print to the current pager handle, or STDOUT if it's not opened | ||||||||||||||||||||||||||||
| 240 | sub _pager_close { | ||||||||||||||||||||||||||||
| 241 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_pager_close: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 242 | 0 | ▶ | my $pager = $self->pager or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | 0 | ▶ | $pager->close if (ref($pager) and $pager->can('close')); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $pager and $pager->can("close")
MC/DC0%0/2
ref $pager and $pager->can("close")
ref $pager
$pager->can("close")
Truth table0%0/3
A and B
A= ref $pagerB= $pager->can("close")
| |||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | 0 | $self->pager( undef ); | |||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | 0 | select $self->_old_outfh; | |||||||||||||||||||||||||||
| 249 | 0 | $SIG{PIPE} = $self->_old_sigpipe; | |||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | 0 | return 1; | |||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | { | ||||||||||||||||||||||||||||
| 257 | 1 | my $win32_console; | |||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | ### determines row count of current terminal; defaults to 25. | ||||||||||||||||||||||||||||
| 260 | ### used by the pager functions | ||||||||||||||||||||||||||||
| 261 | sub _term_rowcount { | ||||||||||||||||||||||||||||
| 262 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_term_rowcount: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||
| 263 | 0 | my $cpan = $self->backend; | |||||||||||||||||||||||||||
| 264 | 0 | my %hash = @_; | |||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | 0 | my $default; | |||||||||||||||||||||||||||
| 267 | 0 | my $tmpl = { | |||||||||||||||||||||||||||
| 268 | default => { default => 25, allow => qr/^\d$/, | ||||||||||||||||||||||||||||
| 269 | store => \$default } | ||||||||||||||||||||||||||||
| 270 | }; | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | 0 | ▶ | check( $tmpl, \%hash ) or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | 0 | ▶ | if ( $^O eq 'MSWin32' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 275 | 0 | ▶ | if ( can_load( modules => { 'Win32::Console' => '0.0' } ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 276 | 0 | ▶ | $win32_console ||= Win32::Console->new(); | ||||||||||||||||||||||||||
|
Condition0%0/3
$win32_console ||= "Win32::Console"->new
MC/DC0%0/2
$win32_console ||= "Win32::Console"->new
$win32_console
"Win32::Console"->new
Truth table0%0/3
A ||= B
A= $win32_consoleB= "Win32::Console"->new
| |||||||||||||||||||||||||||||
| 277 | 0 | my $rows = ($win32_console->Info)[-1]; | |||||||||||||||||||||||||||
| 278 | 0 | return $rows; | |||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | } else { | ||||||||||||||||||||||||||||
| 282 | 0 | local $Module::Load::Conditional::VERBOSE = 0; | |||||||||||||||||||||||||||
| 283 | 0 | ▶ | if ( can_load(modules => {'Term::Size' => '0.0'}) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 284 | 0 | my ($cols, $rows) = Term::Size::chars(); | |||||||||||||||||||||||||||
| 285 | 0 | return $rows; | |||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||
| 288 | 0 | return $default; | |||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | ### Custom print routines, mainly to be able to catch output | ||||||||||||||||||||||||||||
| 293 | ### in test cases, or redirect it if need be | ||||||||||||||||||||||||||||
| 294 | 1 | { sub __print { | |||||||||||||||||||||||||||
| 295 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
__print: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 296 | 0 | print @_; | |||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | sub __printf { | ||||||||||||||||||||||||||||
| 300 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
__printf: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 301 | 0 | my $fmt = shift; | |||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | ### MUST specify $fmt as a separate param, and not as part | ||||||||||||||||||||||||||||
| 304 | ### of @_, as it will then miss the $fmt and return the | ||||||||||||||||||||||||||||
| 305 | ### number of elements in the list... =/ --kane | ||||||||||||||||||||||||||||
| 306 | 0 | $self->__print( sprintf( $fmt, @_ ) ); | |||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | 1 | 1; | |||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | =pod | ||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | =head1 BUG REPORTS | ||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | Please report bugs or other issues to E<lt>bug-cpanplus@rt.cpan.org<gt>. | ||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | This module by Jos Boumans E<lt>kane@cpan.orgE<gt>. | ||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||
| 324 | The CPAN++ interface (of which this module is a part of) is copyright (c) | ||||||||||||||||||||||||||||
| 325 | 2001 - 2007, Jos Boumans E<lt>kane@cpan.orgE<gt>. All rights reserved. | ||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | This library is free software; you may redistribute and/or modify it | ||||||||||||||||||||||||||||
| 328 | under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | L<CPANPLUS::Shell::Default>, L<CPANPLUS::Shell::Classic>, L<cpanp> | ||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | =cut | ||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | # Local variables: | ||||||||||||||||||||||||||||
| 337 | # c-indentation-style: bsd | ||||||||||||||||||||||||||||
| 338 | # c-basic-offset: 4 | ||||||||||||||||||||||||||||
| 339 | # indent-tabs-mode: nil | ||||||||||||||||||||||||||||
| 340 | # End: | ||||||||||||||||||||||||||||
| 341 | # vim: expandtab shiftwidth=4: | ||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||