File Coverage

blib/lib/Devel/MAT/Tool/Tools.pm
Criterion Covered Total %
statement 26 39 66.6
branch 0 6 0.0
condition 0 5 0.0
subroutine 9 11 81.8
pod 0 1 0.0
total 35 62 56.4


line stmt bran cond sub pod time code
1             # You may distribute under the terms of either the GNU General Public License
2             # or the Artistic License (the same terms as Perl itself)
3             #
4             # (C) Paul Evans, 2022 -- leonerd@leonerd.org.uk
5              
6             package Devel::MAT::Tool::Tools 0.51;
7              
8 4     4   2541 use v5.14;
  4         16  
9 4     4   24 use warnings;
  4         8  
  4         125  
10 4     4   22 use base qw( Devel::MAT::Tool );
  4         10  
  4         392  
11              
12 4     4   29 use constant CMD => "tools";
  4         10  
  4         251  
13 4     4   26 use constant CMD_DESC => "List the available tools";
  4         14  
  4         1019  
14              
15             sub run
16             {
17 0     0 0   my $self = shift;
18              
19 0           my @table;
20              
21 0           foreach my $tool ( sort Devel::MAT->available_tools ) {
22 0           my $tool_class = "Devel::MAT::Tool::$tool";
23 0 0 0       next unless $tool_class->can( "FOR_UI" ) and $tool_class->FOR_UI;
24              
25 0 0         my $desc = $tool_class->can( "TOOL_DESC" ) ? $tool_class->TOOL_DESC : undef;
26              
27 0           my $loaded = $self->pmat->has_tool( $tool );
28              
29 0 0 0       push @table, [
30             String::Tagged->from_sprintf( "%s %s",
31             ( $loaded ? Devel::MAT::Cmd->format_note( "*", 1 ) : " " ),
32             Devel::MAT::Cmd->format_note( $tool, 0 ),
33             ),
34             $desc // ""
35             ];
36             }
37              
38 0           Devel::MAT::Cmd->print_table( \@table, sep => " - " );
39             }
40              
41             package # hide
42             Devel::MAT::Tool::Tools::_tool;
43              
44 4     4   37 use base qw( Devel::MAT::Tool );
  4         16  
  4         406  
45              
46 4     4   32 use constant CMD => "tool";
  4         25  
  4         254  
47 4     4   27 use constant CMD_DESC => "Load an extension tool";
  4         8  
  4         255  
48              
49 4         483 use constant CMD_ARGS => (
50             { name => "tool", help => "the name of the tool to load" },
51 4     4   46 );
  4         20  
52              
53             sub run
54             {
55 0     0     my $self = shift;
56 0           my ( $toolname ) = @_;
57              
58 0           my $tool = $self->pmat->load_tool( $toolname, progress => $self->{progress} );
59 0           $self->report_progress();
60             }
61              
62             0x55AA;