Anego/CLI.pm untested

filter: Statementstmt 0.0% 0 / 37 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 51 CC 2 SCAR 10.6
CC
2
Cov
0%
run
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.9
1 package Anego::CLI;
2 use strict;
3 use warnings;
4 use utf8;
5 use Getopt::Long;
6 use Module::Load;
7 use Try::Tiny;
8  
9 use Anego::Logger;
10  
11 sub run {
12 my ($self, @args) = @_;
13  
14 local @ARGV = @args;
15 my $parser = Getopt::Long::Parser->new(
16 config => [ "no_ignore_case", "pass_through" ],
17 );
18 $parser->getoptions(
19 "config=s" => \$Anego::Config::CONFIG_PATH,
20 );
21  
22 my @commands = @ARGV;;
23 my $command = shift @commands || 'help';
24 my $klass = sprintf('Anego::CLI::%s', ucfirst($command));
25  
26 try {
27 Module::Load::load $klass;
28 try {
29 $klass->run(@commands);
30 } catch {
31 errorf("$_\n");
32 };
33 } catch {
34 warnf("Could not find command: %s\n", $command);
35 errorf("$_\n") if $_ !~ /^Can't locate Anego/;
36 exit 2;
37 };
38 }
39  
40 1;