App::Multigit::Repo - Moo class to represent a repo
Holds the name and config for a repo, to make future chaining code cleaner.
You can curry objects is what I mean.
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.
The config from the mgconfig file for this repo.
This is given a dir key if the config does not already specify one.
dir
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 %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.
%data
If it is an ARRAY ref, it is run with IO::Async::Process, with stdout sent to the process's STDIN.
stdout
A Future object is returned. When the command finishes, the Future is completed with a hash-shaped list identical to the one run accepts.
run
If an error occurs before running the command (i.e. if IO::Async throws the error), it will behave as though an error occurred within the command, and exitcode will be set to 255.
exitcode
run accepts a hash of data. If stdout or stderr are provided here, the Future will have these values in past_stdout and past_stderr, and stdout and stderr will get populated with the new STDOUT and STDERR from the provided $command.
stderr
past_stdout
past_stderr
$command
$?
past_stdout and past_stderr are never used; they are provided for you to write any procedure you may require to concatenate new output with old. See gather.
gather
The special key ia_config to the %data hash will be removed from the hash and used as configuration for the IO::Async::Process object that powers the whole system.
ia_config
It currently supports the no_cd option, to prevent attempting to chdir into the repo's directory.
no_cd
chdir
$repo->run($subref, ia_config => { no_cd => 1 });
Intended for currying. This goes between runs and ensures output is not lost.
Concatenates the STDOUT and STDERR from the command with the respective STDOUT or STDERR of the previous command and continues the chain.
$repo->run([qw/git command/]) ->then($repo->curry::run([qw/another git command/])) ->then($repo->curry::gather) ->then(App::Multigit::report($repo))
See run for the shape of the data
Intended for currying, and accepts a hash-shaped list à la run.
Returns a Future that yields a two-element list of the directory - from the config - and the STDOUT from the command, indented with tabs.
Use gather to collect STDOUT/STDERR from previous commands too.
The yielded list is intended for use as a hash constructor.
my $future = App::Multigit::each(sub { my $repo = shift; $repo->run([qw/git command/]) ->then($repo->curry::run([qw/another git command/])) ->then($repo->curry::gather) ->then($repo->curry::report) ; }); my %report = $future->get; for my $dir (sort keys %report) { ... }
Returns a copy of the first argument indented by the number of tabs in the second argument. Not really a method on this class but it's here if you want it.
Alastair McGowan-Douglas, <altreus at perl.org>
<altreus at perl.org>
Please report bugs on the github repository https://github.com/Altreus/App-Multigit.
Copyright 2015 Alastair McGowan-Douglas.
This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:
http://www.perlfoundation.org/artistic_license_2_0
To install App::Multigit, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::Multigit
CPAN shell
perl -MCPAN -e shell install App::Multigit
For more information on module installation, please visit the detailed CPAN module installation guide.