Skip to content

Commit

Permalink
Merge pull request #717 from gugod/list-no-decoration
Browse files Browse the repository at this point in the history
add "--no-decoration" option to "list" command.
  • Loading branch information
gugod committed Mar 16, 2021
2 parents c2a0689 + b593442 commit 801c0e4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 12 deletions.
34 changes: 22 additions & 12 deletions lib/App/perlbrew.pm
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ sub parse_cmdline {
'all',
'shell=s',
'no-patchperl',
'no-decoration',

"builddir=s",

Expand Down Expand Up @@ -2084,18 +2085,27 @@ sub run_command_list {
my $self = shift;
my $is_verbose = $self->{verbose};
for my $i ($self->installed_perls) {
printf "%-2s%-20s %-20s %s\n",
$i->{is_current} ? '*' : '',
$i->{name},
( $is_verbose ?
(index($i->{name}, $i->{version}) < 0) ? "($i->{version})" : ''
: '' ),
( $is_verbose ? "(installed on $i->{ctime})" : '' );
for my $lib (@{$i->{libs}}) {
print $lib->{is_current} ? "* " : " ",
$lib->{name}, "\n"
if ($self->{'no-decoration'}) {
for my $i ($self->installed_perls) {
print $i->{name} . "\n";
for my $lib (@{$i->{libs}}) {
print $lib->{name} . "\n";
}
}
} else {
for my $i ($self->installed_perls) {
printf "%-2s%-20s %-20s %s\n",
$i->{is_current} ? '*' : '',
$i->{name},
( $is_verbose ?
(index($i->{name}, $i->{version}) < 0) ? "($i->{version})" : ''
: '' ),
( $is_verbose ? "(installed on $i->{ctime})" : '' );
for my $lib (@{$i->{libs}}) {
print $lib->{is_current} ? "* " : " ",
$lib->{name}, "\n"
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions t/command-list.t
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ describe "list command," => sub {
stdout_like sub { $app->run(); }, qr/^(\s|\*)\sc?perl-?\d\.\d{1,3}[_.]\d{1,2}(\@nobita)?/, 'Cannot find Perl with libraries in output'

};
describe "when `--no-decoration` is given", sub {
it "does not mark anything", sub {
$ENV{PERLBREW_LIB} = "nobita";
my $app = App::perlbrew->new("list", "--no-decoration");
stdout_like sub { $app->run(); }, qr/^perl-?\d\.\d{1,3}[_.]\d{1,2}(@\w+)?/, 'No decoration mark in the output';
};
};
};

describe "when `--no-decoration` is given", sub {
my $app = App::perlbrew->new("list", "--no-decoration");
stdout_like sub { $app->run(); }, qr/^perl-?\d\.\d{1,3}[_.]\d{1,2}(@\w+)?/, 'No decoration mark in the output';
};
};

Expand Down

0 comments on commit 801c0e4

Please sign in to comment.