tools/gen_completions.pl

filter: Statementstmt 91.6% 22 / 24 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 87.5% 28 / 32 CC 2 SCAR 3.5
CC
2
Cov
86%
get_name
2.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
« blib/lib/XML/XSH2/Help.pm ↑ Summary blib/lib/XML/XSH2/Commands.pm »
1 #!/usr/bin/perl
2  
3 # $Id: gen_completions.pl,v 2.1 2004-12-02 19:26:40 pajas Exp $
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use XML::LibXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Text::Wrap qw(wrap);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶if ($ARGV[0]=~'^(-h|--help)?$') {
Branch: 1 branch
BranchTrueFalseTotal
if ($ARGV[0] =~ /^(-h|--help)?$/) 0 1 1
10 0 print <<EOF;
11 Generates a command-list module from RecDescentXML source.
12  
13 Usage: $0 <source.xml>
14  
15 EOF
16 0 exit;
17 }
18  
19 1 print <<'EOF';
20 package XML::XSH2::CompletionList;
21  
22 use strict;
23 use vars qw(@XSH_COMMANDS @XSH_NOXPATH_COMMANDS);
24  
25 @XSH_COMMANDS=qw(
26 EOF
27  
28 sub get_name {
29 186 ▶ my ($r)=@_;
Subroutine get_name: called CC=2 SCAR=7.2
30 186 ▶ return $r->getAttribute('name') ne ""
Branch: 1 branch
BranchTrueFalseTotal
$r->getAttribute('name') ne '' ? : 186 0 186
31 ? $r->getAttribute('name')
32 : $r->getAttribute('id');
33 }
34  
35 1 my $parser=XML::LibXML->new();
36 1 $parser->load_ext_dtd(1);
37 1 $parser->validation(1);
38 1 my $dom=$parser->parse_file($ARGV[0]);
39  
40 1 my $doc=$dom->getDocumentElement();
41  
42 1 foreach (sort map { get_name($_) }
43 $doc->findnodes('./rules/rule[@type="command"]'),
44 $doc->findnodes('./rules/rule[@type="command"]/aliases/alias')) {
45 186 print "$_\n";
46 }
47  
48 1 print ");\n\n1;\n";
49  
« blib/lib/XML/XSH2/Help.pm ↑ Summary blib/lib/XML/XSH2/Commands.pm »