File Coverage

blib/lib/App/Git/Info.pm
Criterion Covered Total %
statement 11 49 22.4
branch 0 16 0.0
condition n/a
subroutine 4 13 30.7
pod 2 2 100.0
total 17 80 21.2


line stmt bran cond sub pod time code
1             package App::Git::Info;
2             $App::Git::Info::VERSION = '0.8.0';
3 1     1   333751 use strict;
  1         2  
  1         47  
4 1     1   7 use warnings;
  1         2  
  1         102  
5 1     1   24 use 5.016;
  1         4  
6 1     1   1028 use autodie;
  1         21700  
  1         5  
7              
8             sub new
9             {
10 0     0 1   my $class = shift;
11              
12 0           my $self = bless {}, $class;
13              
14 0           $self->_init(@_);
15              
16 0           return $self;
17             }
18              
19             sub _argv
20             {
21 0     0     my $self = shift;
22              
23 0 0         if (@_)
24             {
25 0           $self->{_argv} = shift;
26             }
27              
28 0           return $self->{_argv};
29             }
30              
31             sub _init
32             {
33 0     0     my ( $self, $args ) = @_;
34              
35 0 0         my $argv = $args->{argv} or die "specify argv";
36              
37 0           $self->_argv( [ @{$argv} ] );
  0            
38              
39 0           return;
40             }
41              
42             sub _abstract
43             {
44 0     0     return "Displays a summary of information about the git repository.";
45             }
46              
47 0     0     sub _description { return _abstract(); }
48              
49             sub _opt_spec
50             {
51 0     0     return ();
52             }
53              
54             sub _validate_args
55             {
56 0     0     my ( $self, $opt, $args ) = @_;
57              
58             # no args allowed but options!
59 0 0         $self->usage_error("No args allowed") if @$args;
60              
61 0           return;
62             }
63              
64             sub _execute
65             {
66 0     0     my ( $self, $opt, $args ) = @_;
67              
68 0           my $ST = `git status`;
69 0 0         if ($?)
70             {
71 0           return;
72             }
73              
74 0           my $ret =
75             ( $ST =~
76 0 0         s#\A(On branch \S+\n)((?:\S[^\n]*\n)?).*#"⇒ $1".($2 ? "⇒ $2" : "")#emrs
77             . `git status -s`
78             . "⇒ Remotes:\n"
79             . `git remote -v` );
80 0           chomp $ret;
81 0           say $ret;
82              
83 0           return;
84             }
85              
86             sub run
87             {
88 0     0 1   my $self = shift;
89 0           my $argv = [ @{ $self->_argv() } ];
  0            
90              
91 0 0         if ( not @$argv )
92             {
93 0           die
94             qq#Must include a verb/action command - e.g "git-info info" or "git-info help"#;
95             }
96              
97 0           my $cmd = shift @$argv;
98              
99 0 0         if ( $cmd eq "info" )
    0          
100             {
101 0           return $self->_execute( undef(), $argv, );
102             }
103             elsif ( $cmd eq "help" )
104             {
105 0           print <<'ENDOFHELP';
106             git-info info - Displays a summary of information about the git repository.
107              
108             ENDOFHELP
109             }
110             else
111             {
112 0           die "must be git-info info!";
113             }
114             }
115              
116             1;
117              
118             __END__