App-Multigit

 view release on metacpan or  search on metacpan

lib/App/Multigit/Repo.pm  view on Meta::CPAN

package App::Multigit::Repo;

use App::Multigit::Loop qw(loop);
use IO::Async::Process;
use Future;
use Moo;
use Cwd 'getcwd';
use Try::Tiny;

use 5.014;

our $VERSION = '0.18';

=encoding utf8

=head1 NAME

App::Multigit::Repo - Moo class to represent a repo

=head1 DESCRIPTION

Holds the name and config for a repo, to make future chaining code cleaner.

You can curry objects is what I mean.

=head1 PROPERTIES

=head2 name

Name as in the key from the mgconfig file that defines this repo. As in, the
URL.

It's called name because it doesn't have to be the URL, but is by default.

=cut

has name => (
    is => 'ro',
);

=head2 config

The config from the mgconfig file for this repo.

This is given a C<dir> key if the config does not already specify one.

=cut

has config => (
    is => 'ro',
);

=head1 METHODS

=head2 run($command, [%data])

Run a command, in one of two ways:

If the command is a CODE ref, it is run with this Repo object, and the entirety
of C<%data>. The CODE reference should use normal print/say/warn/die behaviour.
Its return value is discarded. If the subref returns at all, it is considered to
have succeeded.

If it is an ARRAY ref, it is run with IO::Async::Process, with C<stdout> sent
to the process's STDIN.

A Future object is returned. When the command finishes, the Future is completed
with a hash-shaped list identical to the one C<run> accepts.



( run in 0.553 second using v1.01-cache-2.11-cpan-39bf76dae61 )