1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# This file belongs to TLPM v2.20, TeX Live Package Manager
# Public Domain, P.Jackowski@gust.org.pl
# list [-pfe] <mask>
# list packages matching <mask>
sub list
{
my ($arg,$reg,$mask);
my $pkges = $source_pkges;
local $tl_target_new;
local $list_method = \&list_packages;
local $reg_method = \&string2reg;
local $read_method = \&read_source;
while(defined($arg = shift))
{
$arg eq '' and next
or &no_opt($arg) and $mask = $arg
or &is_opt($arg,'f','files') and $list_method = \&list_files
or &is_opt($arg,'p','packages') and $list_method = \&list_packages
or &is_opt($arg,'e','expression') and $reg_method = \&string2preg
or &is_opt($arg,'d','directory') and $read_method = \&read_target
and $pkges = $target_pkges
and do {$tl_target_new = shift;1}
or &is_opt($arg,'h','help') and return $heeelp -> ('list')
or &rem_opt($arg) and return $error{'wrong_opt'} -> ($arg,'list --help');
}
eval '$reg = $reg_method -> ($mask)';
if($@){return $error{'wrong_reg'} -> ($mask)}
return if $read_method -> ();
return $list_method -> ($reg,$pkges);
}
sub list_packages
{
my ($reg,$pkges) = @_;
my $count = 0;
$mess -> (grep {/$reg/ and ++$count} &get_pkg_all($pkges));
$mess -> ("\n");
if($tlpm_redir < 2)
{
$message -> (&one_or_more($count,'matching package','matching packages'));
}
}
sub list_files
{
my ($reg,$pkges) = @_;
my $count = 0;
$mess -> (grep {/$reg/ and ++$count} &get_file_all($pkges));
$mess -> ("\n");
if($tlpm_redir < 2)
{
$message -> (&one_or_more($count,'matching file','matching files'));
}
}
1;
|