Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add "--no-decoration" option to "list" command. #717

Merged
merged 1 commit into from
Mar 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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