The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Git::Background::Future - use Future with Git::Background

VERSION

Version 0.008

SYNOPSIS

    use Git::Background 0.008;
    my $future = Git::Background->run(qw(status -s));

    my @stdout = $future->stdout;

    my ($stdout_ref, $stderr_ref, $exit_code, $stdout_path, $stderr_path) =
        $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 default is to read the output from Git on its stdout and stderr as UTF-8.

The strings returned by the get, stderr, and stdout methods 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.

Current API available since 0.002.

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.

Current API available since 0.002.

exit_code

Calls get, then returns the exit code of the Git process.

Because this command calls get, the same exceptions can be thrown.

Current API available since 0.002.

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, exit_code, stdout_path, and stderr_path. See get for a description of these values.

Current API available since 0.008.

get

Waits for the running Git process to finish by calling await. Throws a Future::Exception if the Future didn't finish successfully. Returns a list of stdout_ref, stderr_ref, exit_code, stdout_path, and stderr_path.

    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;

stdout_ref

An array reference containing the stdout from git, split into lines and chomped.

stderr_ref

An array reference containing the stderr from git, split into lines and chomped.

exit_code

The exit code from git.

stdout_path

A Path::Tiny object of a file containing the stdout from Git. This can be used to read the data with a different binmode.

stderr_path

A Path::Tiny object of a file containing the stderr from Git.

Current API available since 0.008.

is_done

"is_done" in Future

Current API available since 0.002.

is_failed

"is_failed" in Future

Current API available since 0.002.

is_ready

"is_ready" in Future

Current API available since 0.002.

path_stderr

Calls get, then returns the Path::Tiny object for the file containing the stderr from Git.

Because this command calls get, the same exceptions can be thrown.

Current API available since 0.008.

path_stdout

Calls get, then returns the Path::Tiny object for the file containing the stdout from Git.

Because this command calls get, the same exceptions can be thrown.

Current API available since 0.008.

state

"state" in Future

Current API available since 0.002.

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.

Current API available since 0.002.

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.

Current API available since 0.002.

SEE ALSO

Git::Background, Future, Path::Tiny

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>