| 1 | package Mail::MtPolicyd::Client::App; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 1 | our $VERSION = '2.01'; # VERSION | |||||||||
| 6 | # ABSTRACT: application interface class for Mail::MtPolicyd::Client | ||||||||||
| 7 | |||||||||||
| 8 | |||||||||||
| 9 | 1 | extends 'Mail::MtPolicyd::Client'; | |||||||||
| 10 | 1 | with 'MooseX::Getopt'; | |||||||||
| 11 | |||||||||||
| 12 | 1 | ▶ | use Mail::MtPolicyd::Client::Request; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 1 | ▶ | use IO::Handle; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 1 | has '+host' => ( | |||||||||
| 16 | traits => ['Getopt'], | ||||||||||
| 17 | cmd_aliases => "h", | ||||||||||
| 18 | documentation => "host:port of a policyd", | ||||||||||
| 19 | ); | ||||||||||
| 20 | |||||||||||
| 21 | 1 | has '+socket_path' => ( | |||||||||
| 22 | traits => ['Getopt'], | ||||||||||
| 23 | cmd_aliases => "s", | ||||||||||
| 24 | documentation => "path to a socket of a policyd", | ||||||||||
| 25 | ); | ||||||||||
| 26 | |||||||||||
| 27 | |||||||||||
| 28 | 1 | has '+keepalive' => ( | |||||||||
| 29 | traits => ['Getopt'], | ||||||||||
| 30 | cmd_aliases => "k", | ||||||||||
| 31 | documentation => "use connection keepalive?", | ||||||||||
| 32 | ); | ||||||||||
| 33 | |||||||||||
| 34 | 1 | has 'verbose' => ( | |||||||||
| 35 | is => 'rw', | ||||||||||
| 36 | isa => 'Bool', | ||||||||||
| 37 | default => 0, | ||||||||||
| 38 | traits => ['Getopt'], | ||||||||||
| 39 | cmd_aliases => "v", | ||||||||||
| 40 | documentation => "be verbose, print input/output to STDERR", | ||||||||||
| 41 | ); | ||||||||||
| 42 | |||||||||||
| 43 | sub run { | ||||||||||
| 44 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
run: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||
| 45 | 0 | my $stdin = IO::Handle->new; | |||||||||
| 46 | 0 | $stdin->fdopen(fileno(STDIN),"r"); | |||||||||
| 47 | |||||||||||
| 48 | 0 | ▶ | while( my $request = Mail::MtPolicyd::Client::Request->new_from_fh( $stdin ) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | 0 | ▶ | if( $self->verbose ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | 0 | $self->_dump('>> ', $request->as_string); | |||||||||
| 51 | } | ||||||||||
| 52 | 0 | my $response = $self->request( $request ); | |||||||||
| 53 | 0 | ▶ | if( $self->verbose ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 54 | 0 | $self->_dump('<< ', $response->as_string); | |||||||||
| 55 | } | ||||||||||
| 56 | 0 | print $response->action."\n"; | |||||||||
| 57 | } | ||||||||||
| 58 | 0 | return; | |||||||||
| 59 | } | ||||||||||
| 60 | |||||||||||
| 61 | sub _dump { | ||||||||||
| 62 | 0 | ▶ | my ( $self, $prefix, $message ) = @_; | ||||||||
|
Subroutine
_dump: not called CC=1 SCAR=6.9
| |||||||||||
| 63 | 0 | $message =~ s/^/$prefix/mg; | |||||||||
| 64 | 0 | print STDERR $message; | |||||||||
| 65 | 0 | return; | |||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | |||||||||||
| 69 | 1 | 1; | |||||||||
| 70 | |||||||||||
| 71 | __END__ | ||||||||||
| 72 | |||||||||||
| 73 | =pod | ||||||||||
| 74 | |||||||||||
| 75 | =encoding UTF-8 | ||||||||||
| 76 | |||||||||||
| 77 | =head1 NAME | ||||||||||
| 78 | |||||||||||
| 79 | Mail::MtPolicyd::Client::App - application interface class for Mail::MtPolicyd::Client | ||||||||||
| 80 | |||||||||||
| 81 | =head1 VERSION | ||||||||||
| 82 | |||||||||||
| 83 | version 2.01 | ||||||||||
| 84 | |||||||||||
| 85 | =head1 SYNOPSIS | ||||||||||
| 86 | |||||||||||
| 87 | use Mail::MtPolicyd::Client::App; | ||||||||||
| 88 | |||||||||||
| 89 | my $app = Mail::MtPolicyd::Client::App->new_with_options(); | ||||||||||
| 90 | $app->run; | ||||||||||
| 91 | |||||||||||
| 92 | =head1 DESCRIPTION | ||||||||||
| 93 | |||||||||||
| 94 | This class provides a application interface for Mail::MtPolicyd::Client. | ||||||||||
| 95 | |||||||||||
| 96 | =head1 SEE ALSO | ||||||||||
| 97 | |||||||||||
| 98 | L<policyd-client>, L<Mail::MtPolicyd::Client> | ||||||||||
| 99 | |||||||||||
| 100 | =head1 AUTHOR | ||||||||||
| 101 | |||||||||||
| 102 | Markus Benning <ich@markusbenning.de> | ||||||||||
| 103 | |||||||||||
| 104 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 105 | |||||||||||
| 106 | This software is Copyright (c) 2014 by Markus Benning <ich@markusbenning.de>. | ||||||||||
| 107 | |||||||||||
| 108 | This is free software, licensed under: | ||||||||||
| 109 | |||||||||||
| 110 | The GNU General Public License, Version 2, June 1991 | ||||||||||
| 111 | |||||||||||
| 112 | =cut | ||||||||||