App-Git-Info

 view release on metacpan or  search on metacpan

lib/App/Git/Info.pm  view on Meta::CPAN

    my $self = shift;

    if (@_)
    {
        $self->{_argv} = shift;
    }

    return $self->{_argv};
}

sub _init
{
    my ( $self, $args ) = @_;

    my $argv = $args->{argv} or die "specify argv";

    $self->_argv( [ @{$argv} ] );

    return;
}

sub _abstract
{
    return "Displays a summary of information about the git repository.";
}

sub _description { return _abstract(); }

sub _opt_spec
{
    return ();
}

sub _validate_args
{
    my ( $self, $opt, $args ) = @_;

    # no args allowed but options!
    $self->usage_error("No args allowed") if @$args;

    return;
}

sub _execute
{
    my ( $self, $opt, $args ) = @_;

    my $ST = `git status`;
    if ($?)
    {
        return;
    }

    my $ret =
        ( $ST =~
s#\A(On branch \S+\n)((?:\S[^\n]*\n)?).*#"⇒ $1".($2 ? "⇒ $2" : "")#emrs
            . `git status -s`
            . "⇒ Remotes:\n"
            . `git remote -v` );
    chomp $ret;
    say $ret;

    return;
}

sub run
{
    my $self = shift;
    my $argv = [ @{ $self->_argv() } ];

    if ( not @$argv )
    {
        die
qq#Must include a verb/action command - e.g "git-info info" or "git-info help"#;
    }

    my $cmd = shift @$argv;

    if ( $cmd eq "info" )
    {
        return $self->_execute( undef(), $argv, );
    }
    elsif ( $cmd eq "help" )
    {
        print <<'ENDOFHELP';
git-info info - Displays a summary of information about the git repository.

ENDOFHELP
    }
    else
    {
        die "must be git-info info!";
    }
}

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

App::Git::Info - Displays a summary of information about the git repository.

=head1 VERSION

version 0.8.0

=head1 SYNOPSIS

    shlomif[perl-begin]:$trunk$ git info info
    ⇒ On branch master
    ⇒ Your branch is up to date with 'origin/master'.
    ?? y.txt
    ⇒ Remotes:
    origin  git@github.com:shlomif/perl-begin.git (fetch)
    origin  git@github.com:shlomif/perl-begin.git (push)
    shlomif[perl-begin]:$trunk$



( run in 0.309 second using v1.01-cache-2.11-cpan-5511b514fd6 )