| 1 | #!/usr/local/bin/perl | ||||||||||||
| 2 | |||||||||||||
| 3 | 53 | ▶ | use 5.006; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 53 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 53 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | |||||||||||||
| 7 | 53 | my $VERSION = $File::ANVL::VERSION; | |||||||||||
| 8 | |||||||||||||
| 9 | 53 | ▶ | use File::ANVL; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | 53 | ▶ | use File::OM; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | |||||||||||||
| 12 | 53 | ▶ | use Pod::Usage; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 13 | # this :config allows -h24w80 for '‐h 24 ‐w 80', -vax for --vax or --Vax | ||||||||||||
| 14 | 53 | ▶ | use Getopt::Long qw(:config bundling_override); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 15 | |||||||||||||
| 16 | 53 | my %opt = ( | |||||||||||
| 17 | comments => 0, | ||||||||||||
| 18 | find => 0, | ||||||||||||
| 19 | format => 0, | ||||||||||||
| 20 | help => 0, | ||||||||||||
| 21 | invert => 0, | ||||||||||||
| 22 | listformats => 0, | ||||||||||||
| 23 | man => 0, | ||||||||||||
| 24 | predns => 0, | ||||||||||||
| 25 | show => 0, | ||||||||||||
| 26 | subjelpat => 0, | ||||||||||||
| 27 | version => 0, | ||||||||||||
| 28 | verbose => 0, | ||||||||||||
| 29 | ); | ||||||||||||
| 30 | |||||||||||||
| 31 | # main | ||||||||||||
| 32 | { | ||||||||||||
| 33 | 53 | ▶ | GetOptions(\%opt, | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 34 | 'comments', | ||||||||||||
| 35 | 'find=s', | ||||||||||||
| 36 | 'format|m=s', | ||||||||||||
| 37 | 'help|h|?', | ||||||||||||
| 38 | 'invert', | ||||||||||||
| 39 | 'listformats', | ||||||||||||
| 40 | 'man', | ||||||||||||
| 41 | 'predns=s', | ||||||||||||
| 42 | 'show=s', | ||||||||||||
| 43 | 'subjelpat=s', | ||||||||||||
| 44 | 'version', | ||||||||||||
| 45 | 'verbose|v', | ||||||||||||
| 46 | ) | ||||||||||||
| 47 | or pod2usage(-exitstatus => 2, -verbose => 1); | ||||||||||||
| 48 | |||||||||||||
| 49 | 53 | ▶ | $opt{help} and pod2usage(-exitstatus => 0, -verbose => 1); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 50 | 53 | ▶ | $opt{man} and pod2usage(-exitstatus => 0, -verbose => 2); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 51 | 53 | ▶ | $opt{version} and print("$VERSION\n"), exit 0; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 52 | $opt{listformats} and | ||||||||||||
| 53 | 53 | ▶ | print(join("\n", File::OM::listformats()), "\n"), | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 54 | exit 0; | ||||||||||||
| 55 | |||||||||||||
| 56 | # Format may be a name, optionally followed by a colon and a | ||||||||||||
| 57 | # list of element names to be output. | ||||||||||||
| 58 | # | ||||||||||||
| 59 | 52 | ▶ | my $format = $opt{format} || 'anvl'; # given format name | ||||||||||
|
Condition100%2/2
$opt{'format'} || 'anvl'
MC/DC100%1/1
$opt{'format'} || 'anvl'
$opt{'format'}
Truth table100%2/2
A
A= $opt{'format'}
| |||||||||||||
| 60 | 52 | my $r_elem_order; | |||||||||||
| 61 | 52 | ▶ | $format =~ /^([^:]*):\s*(.*)\s*/ and | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 62 | ($format, @$r_elem_order) = (lc($1), split(/\s*\|\s*/, $2)); | ||||||||||||
| 63 | |||||||||||||
| 64 | # # If an element ordering is defined, change any empty element | ||||||||||||
| 65 | # # names to the element name ("_"), which grabs any unlabeled | ||||||||||||
| 66 | # # value that might start the record. | ||||||||||||
| 67 | # # | ||||||||||||
| 68 | # $r_elem_order and | ||||||||||||
| 69 | # @$r_elem_order = map($_ || '_', @$r_elem_order); | ||||||||||||
| 70 | |||||||||||||
| 71 | # output formats to do: anvlr, granvl, yaml, short erc/anvl, csv | ||||||||||||
| 72 | # XXX need a default command? anvl_summarize? | ||||||||||||
| 73 | |||||||||||||
| 74 | 52 | my $anvl_opt = File::ANVL::anvl_opt_defaults(); # ref to hash | |||||||||||
| 75 | 52 | $$anvl_opt{comments} = $opt{comments}; # whether to keep comments | |||||||||||
| 76 | 52 | $$anvl_opt{elem_order} = $r_elem_order; # different element order | |||||||||||
| 77 | 52 | $$anvl_opt{find} = $opt{find}; # find records matching regex | |||||||||||
| 78 | 52 | $$anvl_opt{invert} = $opt{invert}; # comma-invert any values | |||||||||||
| 79 | 52 | $$anvl_opt{show} = $opt{show}; # show given elems in recs | |||||||||||
| 80 | 52 | $$anvl_opt{verbose} = $opt{verbose}; # more output | |||||||||||
| 81 | |||||||||||||
| 82 | # While anvl_opt and om_opt share some keys, they're used differently. | ||||||||||||
| 83 | |||||||||||||
| 84 | my %om_opt = ( | ||||||||||||
| 85 | comments => $opt{comments}, | ||||||||||||
| 86 | outhandle => *STDOUT, | ||||||||||||
| 87 | verbose => $opt{verbose}, | ||||||||||||
| 88 | 52 | ); | |||||||||||
| 89 | $opt{predns} and # predicate namespace | ||||||||||||
| 90 | 52 | ▶ | $om_opt{turtle_predns} = $opt{predns}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 91 | $opt{subjelpat} and # subject element name pattern | ||||||||||||
| 92 | 52 | ▶ | $om_opt{turtle_subjelpat} = $opt{subjelpat}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 93 | |||||||||||||
| 94 | 52 | ▶ | my $om = File::OM->new($format, \%om_opt) or | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 95 | pod2usage("$0: unknown format: $format"); | ||||||||||||
| 96 | |||||||||||||
| 97 | 52 | my $st = File::ANVL::anvl_om($om, $anvl_opt); | |||||||||||
| 98 | 52 | ▶ | $st ne 1 and die "anvl: $st"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 99 | # | ||||||||||||
| 100 | # If 'outhandle' had been set to '', we would expect $st to contain | ||||||||||||
| 101 | # the complete output string built up by anvl_om. | ||||||||||||
| 102 | |||||||||||||
| 103 | 52 | exit 0; | |||||||||||
| 104 | } | ||||||||||||
| 105 | |||||||||||||
| 106 | __END__ | ||||||||||||