#!/usr/bin/perl
use Getopt::Euclid;
=head1 NAME
egypt metrics - egypt's metric reporting tool
=head1 SYNOPSIS
egypt metrics [options] [<input> ...]
=head1 DESCRIPTION
egypt metrics analyzes source code in the directories passed as arguments and
procudes a matrics report. Such report is written to the standard output in the
YAML format (see I<http://www.yaml.org/>)
egypt metrics is part of the egypt suite.
=head1 OPTIONS
=over
=item --extractor <extractor>
Define wich extractor method use to analise source code. Default is Doxyparse.
=for Euclid:
extractor.type: string, extractor =~ /\A\w+\Z/
extractor.default: 'Doxyparse'
When using using GCC extractor, the directories will be parsed to find files
matching *.rtl and *.expand. For info about how to generate those files, please
see Egypt::Extractor::GCC(3).
When using the Doxyparse extractor (default), all files matching the languages
supported by doxyparse are processed.
=item --help
Displays a help message on how to use this tool.
=item --list
Displays metric list
=item <input>...
Tells egypt which source code directory(ies) you want to parse.
=for Euclid:
input.type: readable
=item --output <file>
Use a file as output
=for Euclid:
file.type: writeable
=back
=head1 OUTPUT FORMAT
The output is a stream of YAML documents. The first one presents metrics for
the project as a whole. The subsequent ones present per-module metrics, and thus
there will be as many of them as there are modules in your project.
=head1 COPYRIGHT AND AUTHORS
See egypt(1)
=cut
use strict;
use Egypt::Extractor;
use Egypt::Metrics;
if($ARGV{'--list'}){
my $metrics_handler = new Egypt::Metrics(model => new Egypt::Model);
my %metrics = $metrics_handler->list_of_metrics();
foreach my $key (sort keys %metrics){
print "$key - $metrics{$key}\n";
}
exit(0);
}
if($ARGV{'<input>'} =~ /^\s*$/){
printf("%s: No input files!\n", 'egypt metrics');
exit(0);
}
my $extractor = Egypt::Extractor->load($ARGV{'--extractor'});
my $metrics = Egypt::Metrics->new(model => $extractor->model);
$extractor->process(@{$ARGV{'<input>'}});
open STDOUT, '>', $ARGV{'--output'} if $ARGV{'--output'};
print $metrics->report;
close STDOUT;
exit(0);