- NAME
- SYNOPSIS
- DESCRIPTION
- CONSTRUCTOR
  - new()
- METHODS
  - err_buffer()
  - out_buffer()
  - run( $command, $arg1, ..., $argN, \%options )
  - run_or_die( $command, $arg1, ..., $argN, \%options )
- AUTHOR
- COPYRIGHT

# NAME

IPC::Open3::Callback::CommandRunner - A utility class that wraps IPC::Open3::Callback with available output buffers and an option to die on failure instead of returning exit code.

# SYNOPSIS

      use IPC::Open3::Callback::CommandRunner;

      my $command_runner = IPC::Open3::Callback::CommandRunner->new();
      my $exit_code = $command_runner->run( 'echo Hello, World!' );

      eval {
          $command_runner->run_or_die( $command_that_might_die );
      };
      if ( $@ ) {
          print( "command died: $@\n" );
      }

# DESCRIPTION

Adds more convenience to IPC::Open3::Callback by buffering output and error if needed and dieing on failure if wanted.

# CONSTRUCTOR

## new()

The constructor creates a new CommandRunner.

# METHODS

## err_buffer()

Returns the contents of the err_buffer from the last call to run or run_or_die.

## out_buffer()

Returns the contents of the err_buffer from the last call to run or run_or_die.

## run( $command, $arg1, ..., $argN, \%options )

Will run the specified command with the supplied arguments by passing them on to run_command. Arguments can be embedded in the command string and are thus optional.

If the last argument to this method is a hashref (`ref(@_[-1]) eq 'HASH'`), then it is treated as an options hash. The supported allowed options are the same as run_command plus:

out_buffer

  If true, a callback will be generated for `STDOUT` that buffers all data and can be accessed via out_buffer()

err_buffer

  If true, a callback will be generated for `STDERR` that buffers all data and can be accessed via err_buffer()

Returns the exit code from the command.

## run_or_die( $command, $arg1, ..., $argN, \%options )

The same as run exept that it will `die` on a non-zero exit code instead of returning the exit code.

# AUTHOR

Lucas Theisen (lucastheisen@pastdev.com)

# COPYRIGHT

Copyright 2013 pastdev.com. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.