File Coverage

blib/lib/PGP/Finger/App.pm
Criterion Covered Total %
statement 15 26 57.6
branch 0 2 0.0
condition n/a
subroutine 5 7 71.4
pod 0 1 0.0
total 20 36 55.5


line stmt bran cond sub pod time code
1             package PGP::Finger::App;
2              
3 1     1   928 use Moose;
  1         2  
  1         5  
4              
5             our $VERSION = '1.1'; # VERSION
6             # ABSTRACT: commandline interface to PGP::Finger
7              
8             extends 'PGP::Finger';
9             with 'MooseX::Getopt';
10              
11 1     1   4171 use PGP::Finger::DNS;
  1         1  
  1         11  
12 1     1   19 use PGP::Finger::Keyserver;
  1         1  
  1         7  
13 1     1   14 use PGP::Finger::GPG;
  1         2  
  1         4  
14 1     1   15 use PGP::Finger::File;
  1         1  
  1         4  
15              
16             has '+sources' => (
17             traits => [ 'NoGetopt' ],
18             default => sub {
19             my $self = shift;
20             my @srcs;
21             foreach my $q ( @{$self->_query} ) {
22             my $src;
23             $q = lc($q);
24             if( $q eq 'dns' ) {
25             $src = PGP::Finger::DNS->new();
26             } elsif( $q eq 'keyserver' ) {
27             $src = PGP::Finger::Keyserver->new();
28             } elsif( $q eq 'gpg' ) {
29             $src = PGP::Finger::GPG->new();
30             } elsif( $q eq 'file' ) {
31             $src = PGP::Finger::File->new(
32             input => $self->input,
33             format => $self->format,
34             );
35             } else {
36             die('unknown query type: '.$q);
37             }
38             push( @srcs, $src );
39             }
40             return( \@srcs );
41             },
42             );
43              
44             has 'format' => ( is => 'ro', isa => 'Str', default => 'armored',
45             traits => ['Getopt'],
46             cmd_aliases => 'f',
47             documentation => 'format of input (armored or binary)',
48             );
49              
50             has 'input' => ( is => 'ro', isa => 'Str', default => '-',
51             traits => ['Getopt'],
52             cmd_aliases => 'i',
53             documentation => 'path or - for stdin',
54             );
55              
56             has 'query' => ( is => 'ro', isa => 'Str', default => 'dns,keyserver',
57             traits => ['Getopt'],
58             cmd_aliases => 'q',
59             documentation => 'sources to query (default: dns,keyserver)',
60             );
61              
62             has '_query' => ( is => 'ro', isa => 'ArrayRef[Str]', lazy => 1,
63             default => sub {
64             my $self = shift;
65             return [ split(/\s*,\s*/, $self->query) ];
66             },
67             );
68              
69             has 'output' => ( is => 'ro', isa => 'Str', default => 'armored',
70             traits => ['Getopt'],
71             cmd_aliases => 'o',
72             documentation => 'output format: armored,rfc or generic (default: armored)',
73             );
74              
75             sub _usage_format {
76 0     0     return "usage: %c %o <uid> <more uids ...>";
77             }
78              
79             sub run {
80 0     0 0   my $self = shift;
81 0           my @uids = @{$self->extra_argv};
  0            
82              
83 0 0         if( ! @uids ) {
84 0           print $self->usage;
85 0           exit 1;
86             }
87              
88 0           foreach my $uid ( @uids ) {
89 0           my $resultset = $self->fetch( $uid );
90 0           print $resultset->as_string( $self->output );
91             }
92              
93 0           return;
94             }
95              
96             1;
97              
98             __END__
99              
100             =pod
101              
102             =encoding UTF-8
103              
104             =head1 NAME
105              
106             PGP::Finger::App - commandline interface to PGP::Finger
107              
108             =head1 VERSION
109              
110             version 1.1
111              
112             =head1 AUTHOR
113              
114             Markus Benning <ich@markusbenning.de>
115              
116             =head1 COPYRIGHT AND LICENSE
117              
118             This software is Copyright (c) 2015 by Markus Benning.
119              
120             This is free software, licensed under:
121              
122             The GNU General Public License, Version 2 or later
123              
124             =cut