| 1 | package Stepford::Grapher::CommandLine; | ||
| 2 | |||
| 3 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 2 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 2 | our $VERSION = '1.01'; | |
| 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 | 2 | ▶ | use Getopt::Long qw(:config pass_through); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | 2 | ▶ | use Module::Runtime qw(require_module); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | 2 | ▶ | use Stepford::Grapher; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 17 | |||
| 18 | 2 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 19 | |||
| 20 | 2 | has renderer => ( | |
| 21 | is => 'ro', | ||
| 22 | isa => 'Str', | ||
| 23 | default => 'graphviz', | ||
| 24 | documentation => 'The name of the renderer to use', | ||
| 25 | ); | ||
| 26 | |||
| 27 | 2 | with 'MooseX::Getopt::Dashes'; | |
| 28 | |||
| 29 | 2 | ▶ | sub run { |
|
Subroutine
run: called CC=1 SCAR=0.0
Pod
documented
| |||
| 30 | 2 | my $class = shift; | |
| 31 | 2 | my $self = $class->new_with_options; | |
| 32 | |||
| 33 | 2 | my $renderer_classname | |
| 34 | = 'Stepford::Grapher::Renderer::' . ucfirst lc $self->renderer; | ||
| 35 | 2 | 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 | 1 | 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 | 1 | my $grapher = Stepford::Grapher->new_with_options( | |
| 46 | renderer => $renderer, | ||
| 47 | argv => $renderer->extra_argv, | ||
| 48 | ); | ||
| 49 | |||
| 50 | 1 | $grapher->run; | |
| 51 | |||
| 52 | 1 | 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 | 0 | ▶ | around print_usage_text => sub { |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 58 | ## no critic (InputOutput::RequireCheckedSyscalls) | ||
| 59 | 0 | 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-stepford.pl" for an overview. | ||
| 63 | TEXT | ||
| 64 | 2 | }; | |
| 65 | |||
| 66 | 2 | __PACKAGE__->meta->make_immutable; | |
| 67 | 2 | 1; | |
| 68 | |||
| 69 | # ABSTRACT: Module supporting command line interface for Stepford::Grapher | ||
| 70 | |||
| 71 | __END__ | ||