#!/usr/bin/env perl
use strict;
use warnings;

our $VERSION = '0.001004';

use App::Yath::Util qw/load_command/;
use List::Util qw/sum/;
use Time::HiRes qw/time/;

use Test2::Util::Times qw/render_bench/;

my $cmd_name;
if (@ARGV && -f $ARGV[0] && $ARGV[0] =~ m/\.jsonl(\.bz2|\.gz)$/) {
    $cmd_name = 'replay';
}
elsif(!@ARGV || -d $ARGV[0] || -f $ARGV[0] || substr($ARGV[0],0,1) eq '-') {
    $cmd_name = 'test';
}
else {
    $cmd_name = shift @ARGV;
}

my $cmd_class = load_command($cmd_name);

my $cmd = $cmd_class->new(args => \@ARGV);

my $start = time;
my $exit = $cmd->run;

my $end = time;
my $bench = render_bench($start, $end, times);
print $bench, "\n\n";

exit $exit;

__END__

=pod

=encoding UTF-8

=head1 NAME

yath - Primary Command Line Interface (CLI) for Test2::Harness

=head1 DESCRIPTION

=head1 SOURCE

The source code repository for Test2-Harness can be found at
F<http://github.com/Test-More/Test2-Harness/>.

=head1 MAINTAINERS

=over 4

=item Chad Granum E<lt>exodist@cpan.orgE<gt>

=back

=head1 AUTHORS

=over 4

=item Chad Granum E<lt>exodist@cpan.orgE<gt>

=back

=head1 COPYRIGHT

Copyright 2017 Chad Granum E<lt>exodist7@gmail.comE<gt>.

This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.

See F<http://dev.perl.org/licenses/>

=cut
