line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of Config-Model |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is Copyright (c) 2005-2022 by Dominique Dumont. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software, licensed under: |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# The GNU Lesser General Public License, Version 2.1, February 1999 |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use strict; |
12
|
59
|
|
|
59
|
|
355
|
use warnings; |
|
59
|
|
|
|
|
123
|
|
|
59
|
|
|
|
|
1504
|
|
13
|
59
|
|
|
59
|
|
275
|
use Exporter; |
|
59
|
|
|
|
|
108
|
|
|
59
|
|
|
|
|
1319
|
|
14
|
59
|
|
|
59
|
|
239
|
|
|
59
|
|
|
|
|
117
|
|
|
59
|
|
|
|
|
1763
|
|
15
|
|
|
|
|
|
|
use vars qw/@EXPORT/; |
16
|
59
|
|
|
59
|
|
377
|
|
|
59
|
|
|
|
|
129
|
|
|
59
|
|
|
|
|
38253
|
|
17
|
|
|
|
|
|
|
@EXPORT = qw(applications models); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $test = shift || 0; |
20
|
|
|
|
|
|
|
|
21
|
59
|
|
100
|
59
|
0
|
24245
|
my ( %categories, %appli_info, %applications ); |
22
|
|
|
|
|
|
|
my %done_cat; |
23
|
59
|
|
|
|
|
180
|
my @dir_to_scan = $test ? qw/lib/ : @INC; |
24
|
59
|
|
|
|
|
0
|
|
25
|
59
|
100
|
|
|
|
429
|
foreach my $dir ( map { glob("$_/Config/Model/*.d") } @dir_to_scan ) { |
26
|
|
|
|
|
|
|
my ($cat) = ( $dir =~ m!.*/([\w\-]+)\.d! ); |
27
|
59
|
|
|
|
|
134
|
|
|
495
|
|
|
|
|
15810
|
|
28
|
222
|
|
|
|
|
1365
|
if ( $cat !~ /^user|system|application$/ ) { |
29
|
|
|
|
|
|
|
warn "available_models: skipping unexpected category: $cat\n"; |
30
|
222
|
50
|
|
|
|
932
|
next; |
31
|
0
|
|
|
|
|
0
|
} |
32
|
0
|
|
|
|
|
0
|
|
33
|
|
|
|
|
|
|
foreach my $file ( sort glob("$dir/*") ) { |
34
|
|
|
|
|
|
|
next if $file =~ m!/README!; |
35
|
222
|
|
|
|
|
11544
|
next if $file =~ /(~|\.bak|\.orig)$/; |
36
|
333
|
50
|
|
|
|
1209
|
my ($appli) = ( $file =~ m!.*/([\w\-]+)! ); |
37
|
333
|
50
|
|
|
|
1098
|
|
38
|
333
|
|
|
|
|
1380
|
# ensure that an appli file of a cat is not parsed twice |
39
|
|
|
|
|
|
|
# (useful in dev, where system appli file may clobber |
40
|
|
|
|
|
|
|
# appli file in dvelopment |
41
|
|
|
|
|
|
|
next if $done_cat{$cat}{$appli}; |
42
|
|
|
|
|
|
|
|
43
|
333
|
100
|
|
|
|
1045
|
$appli_info{$appli}{_file} = $file; |
44
|
|
|
|
|
|
|
$appli_info{$appli}{_category} = $cat; |
45
|
177
|
|
|
|
|
506
|
open my $fh, '<', $file || die "Can't open file $file:$!"; |
46
|
177
|
|
|
|
|
318
|
while (<$fh>) { |
47
|
177
|
|
50
|
|
|
5469
|
chomp; |
48
|
177
|
|
|
|
|
2468
|
s/^\s+//; |
49
|
236
|
|
|
|
|
570
|
s/\s+$//; |
50
|
236
|
|
|
|
|
590
|
s/#.*//; |
51
|
236
|
|
|
|
|
663
|
my ( $k, $v ) = split /\s*=\s*/; |
52
|
236
|
|
|
|
|
364
|
next unless $v; |
53
|
236
|
|
|
|
|
1049
|
if ( $k =~ /model/i ) { |
54
|
236
|
50
|
|
|
|
541
|
push @{ $categories{$cat} }, $appli unless $done_cat{$cat}{$appli}; |
55
|
236
|
100
|
|
|
|
644
|
$done_cat{$cat}{$appli} = 1; |
56
|
177
|
50
|
|
|
|
477
|
} |
|
177
|
|
|
|
|
567
|
|
57
|
177
|
|
|
|
|
420
|
|
58
|
|
|
|
|
|
|
$appli_info{$appli}{$k} = $v; |
59
|
|
|
|
|
|
|
$applications{$appli} = $v if $k =~ /model/i; |
60
|
236
|
|
|
|
|
497
|
} |
61
|
236
|
100
|
|
|
|
2041
|
die "Missing model line in file $file\n" unless $done_cat{$cat}{$appli}; |
62
|
|
|
|
|
|
|
} |
63
|
177
|
50
|
|
|
|
2245
|
} |
64
|
|
|
|
|
|
|
return \%categories, \%appli_info, \%applications; |
65
|
|
|
|
|
|
|
} |
66
|
59
|
|
|
|
|
504
|
|
67
|
|
|
|
|
|
|
my @i = available_models(@_); |
68
|
|
|
|
|
|
|
return join( ' ', sort values %{ $i[2] } ) . "\n"; |
69
|
|
|
|
|
|
|
} |
70
|
0
|
|
|
0
|
0
|
|
|
71
|
0
|
|
|
|
|
|
my @i = available_models(@_); |
|
0
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
return join( ' ', sort keys %{ $i[2] } ) . "\n"; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
0
|
0
|
|
1; |
76
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# ABSTRACT: List available models and applications |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=pod |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=encoding UTF-8 |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 NAME |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Config::Model::Lister - List available models and applications |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 VERSION |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
version 2.151 |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 SYNOPSIS |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
perl -MConfig::Model::Lister -e'print Config::Model::Lister::models;' |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
perl -MConfig::Model::Lister -e'print Config::Model::Lister::applications;' |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 DESCRIPTION |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Small modules to list available models or applications whose config |
101
|
|
|
|
|
|
|
can be edited by L<cme>. This module is designed to be used by bash |
102
|
|
|
|
|
|
|
completion. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
All functions accept an optional boolean parameter. When true, only |
105
|
|
|
|
|
|
|
the local C<lib> dir is scanned. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 FUNCTIONS |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 available_models |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Returns an array of 3 hash refs: |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=over |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item * |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
category (system or user or application) => application list. E.g. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
{ system => [ 'popcon' , 'fstab'] } |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item * |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
application name to model information. E.g. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
{ 'multistrap' => { model => 'Multistrap', require_config_file => 1 } |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item * |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
application name to model name. E.g. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
{ popcon => 'Popcon', 'multistrap' => 'Multistrap' } |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=back |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 models |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Returns a string with the list of models. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 applications |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Returns a string with the list of editable applications. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 AUTHOR |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Dominique Dumont |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
This software is Copyright (c) 2005-2022 by Dominique Dumont. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This is free software, licensed under: |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
The GNU Lesser General Public License, Version 2.1, February 1999 |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=cut |