| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Anego::CLI; | 
| 2 | 1 |  |  | 1 |  | 746 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 26 |  | 
| 3 | 1 |  |  | 1 |  | 3 | use warnings; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 23 |  | 
| 4 | 1 |  |  | 1 |  | 4 | use utf8; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 3 |  | 
| 5 | 1 |  |  | 1 |  | 763 | use Getopt::Long; | 
|  | 1 |  |  |  |  | 8811 |  | 
|  | 1 |  |  |  |  | 5 |  | 
| 6 | 1 |  |  | 1 |  | 750 | use Module::Load; | 
|  | 1 |  |  |  |  | 1048 |  | 
|  | 1 |  |  |  |  | 6 |  | 
| 7 | 1 |  |  | 1 |  | 533 | use Try::Tiny; | 
|  | 1 |  |  |  |  | 1149 |  | 
|  | 1 |  |  |  |  | 58 |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 | 1 |  |  | 1 |  | 392 | use Anego::Logger; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 302 |  | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | sub run { | 
| 12 | 0 |  |  | 0 | 0 |  | my ($self, @args) = @_; | 
| 13 |  |  |  |  |  |  |  | 
| 14 | 0 |  |  |  |  |  | local @ARGV = @args; | 
| 15 | 0 |  |  |  |  |  | my $parser = Getopt::Long::Parser->new( | 
| 16 |  |  |  |  |  |  | config => [ "no_ignore_case", "pass_through" ], | 
| 17 |  |  |  |  |  |  | ); | 
| 18 | 0 |  |  |  |  |  | $parser->getoptions( | 
| 19 |  |  |  |  |  |  | "config=s" => \$Anego::Config::CONFIG_PATH, | 
| 20 |  |  |  |  |  |  | ); | 
| 21 |  |  |  |  |  |  |  | 
| 22 | 0 |  |  |  |  |  | my @commands = @ARGV;; | 
| 23 | 0 |  | 0 |  |  |  | my $command = shift @commands || 'help'; | 
| 24 | 0 |  |  |  |  |  | my $klass = sprintf('Anego::CLI::%s', ucfirst($command)); | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | try { | 
| 27 | 0 |  |  | 0 |  |  | Module::Load::load $klass; | 
| 28 |  |  |  |  |  |  | try { | 
| 29 | 0 |  |  |  |  |  | $klass->run(@commands); | 
| 30 |  |  |  |  |  |  | } catch { | 
| 31 | 0 |  |  |  |  |  | errorf("$_\n"); | 
| 32 | 0 |  |  |  |  |  | }; | 
| 33 |  |  |  |  |  |  | } catch { | 
| 34 | 0 |  |  | 0 |  |  | warnf("Could not find command: %s\n", $command); | 
| 35 | 0 | 0 |  |  |  |  | errorf("$_\n") if $_ !~ /^Can't locate Anego/; | 
| 36 | 0 |  |  |  |  |  | exit 2; | 
| 37 | 0 |  |  |  |  |  | }; | 
| 38 |  |  |  |  |  |  | } | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  | 1; |