lib/Meta/Grapher/Moose/CommandLine.pm untested

filter: Statementstmt 0.0% 0 / 36 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 45 CC 1 SCAR 6.9
CC
1
Cov
0%
run
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Meta::Grapher::Moose::CommandLine;
2  
3 use strict;
4 use warnings;
5 use namespace::autoclean;
6  
7 our $VERSION = '1.03';
8  
9 # This globally changes the underlying Getopt::Long behavior to allow passing
10 # through of unprocessed dash arguments without error, which allows us to have
11 # multiple classes to have an attempt to read the file. Ideally this wouldn't
12 # be a global setting, but the conclusion of #moose is that this is good
13 # enough
14 use Getopt::Long qw(:config pass_through);
15 use Meta::Grapher::Moose;
16 use Module::Runtime qw(require_module);
17  
18 use Moose;
19  
20 has renderer => (
21 is => 'ro',
22 isa => 'Str',
23 default => 'graphviz',
24 documentation => 'The name of the renderer to use',
25 );
26  
27 with 'MooseX::Getopt::Dashes';
28  
29 sub run {
30 my $class = shift;
31 my $self = $class->new_with_options;
32  
33 my $renderer_classname
34 = 'Meta::Grapher::Moose::Renderer::' . ucfirst lc $self->renderer;
35 require_module($renderer_classname);
36  
37 # Any command line options that we didn't consume are passed onto the
38 # renderer so it gets a chance to process them.
39 my $renderer = $renderer_classname->new_with_options(
40 argv => $self->extra_argv,
41 );
42  
43 # We pass our main object any command line options that aren't consumed by
44 # the renderer and this class
45 my $grapher = Meta::Grapher::Moose->new_with_options(
46 renderer => $renderer,
47 argv => $renderer->extra_argv,
48 );
49  
50 $grapher->run;
51  
52 return;
53 }
54  
55 # We can't just override this since the method created for us was installed
56 # directly in this class. Instead wrap it with around and
57 around print_usage_text => sub {
58 ## no critic (InputOutput::RequireCheckedSyscalls)
59 print <<'TEXT';
60 Many more command line options are available depending on they type of
61 renderer you are using. Please refer to the documentation for the individual
62 renderers or use "perldoc graph-meta.pl" for an overview.
63 TEXT
64 };
65  
66 __PACKAGE__->meta->make_immutable;
67  
68 1;
69  
70 # ABSTRACT: Module supporting command line interface for Meta::Grapher::Moose
71  
72 __END__