NAME
Git::Background::Future - use Future with Git::Background
VERSION
Version 0.007
SYNOPSIS
use Git::Background 0.002;
my $future = Git::Background->run(qw(status -s));
my @stdout = $future->stdout;
my ($stdout_ref, $stderr_ref, $exit_code) = $future->get;
DESCRIPTION
This is a subclass of Future. Please read the excellent documentation of Future
to see what you can do with this module, this man page only describes the changes to Future
specific to Git::Background.
UTF-8
The module assumes that git
s output is UTF-8, which is the default. Before stdout and stderr from git
are read, Git::Background turns on UTF-8 on the file handle with
binmode($fh, ':encoding(UTF-8)');
The strings returned by the get
, stderr
, and stdout
string can therefore contain wide characters. When you write this data to a file handle, you must ensure that the destination also uses a suitable encoding. This is necessary to correctly handle any wide characters in the data. You can do this by setting the encoding of the destination filehandle, e.g.:
binmode(STDOUT, ':encoding(UTF-8)');
USAGE
new( RUN )
New Git::Background::Future
objects should be constructed by using the run
method of Git::Background.
await
Blocks and waits until the Git process finishes.
Returns the invocant future itself, so it is useful for chaining.
This method is called by get
or failure
.
See "await" in Future for more information.
exit_code
Calls get
, then returns the exit code of the Git process.
failure
Waits for the running Git process to finish by calling await
. Returns undef if the future finished successfully, otherwise it returns a list with
$message, $category, @details
For the $category
git
, @details
is a list of stdout_ref
, stderr_ref
, and exit_code
.
get
Waits for the running Git process to finish by calling await
. Throws a Future::Exception if the Future
didn't finish successfully. Returns the stdout, stderr and exit code of the Git process.
my $git = Git::Background->new($dir);
my $future = $git->run('status', '-s');
# waits for 'git status -s' to finish
my ($stdout_ref, $stderr_ref, $rc) = $future->get;
is_done
is_failed
is_ready
state
stderr
Calls get
, then returns all the lines written by the Git command to stderr.
Because this command calls get
, the same exceptions can be thrown.
Note: get
returns all the output lines as array reference, stderr
returns a list.
stdout
Calls get
, then returns all the lines written by the Git command to stdout.
Because this command calls get
, the same exceptions can be thrown.
Note: get
returns all the output lines as array reference, stdout
returns a list.
SEE ALSO
SUPPORT
Bugs / Feature Requests
Please report any bugs or feature requests through the issue tracker at https://github.com/skirmess/Git-Background/issues. You will be notified automatically of any progress on your issue.
Source Code
This is open source software. The code repository is available for public review and contribution under the terms of the license.
https://github.com/skirmess/Git-Background
git clone https://github.com/skirmess/Git-Background.git
AUTHOR
Sven Kirmess <sven.kirmess@kzone.ch>