NAME

ArchWay::Util::RunCmd - add notification capabilities to Arch::Util::run_cmd


SYNOPSIS

    package Some::CommandTracker;
    sub cmd_start ($@) {
        my $this = shift;
        print "executing: [@_]\n";
    }
    sub cmd_output_line ($$) {
        my $this = shift;
        my $line = shift;
        print "\t($line)\n";
    }
    # ...
    package main;
    use Arch::Util qw(run_tla);  # in any order
    use ArchWay::Util::RunCmd;
    ArchWay::Util::RunCmd::observe("Some::CommandTracker");
    my $archives = run_tla("archives", "-n");
    # this may work too
    ArchWay::Util::RunCmd::observe(Some::CommandTracker->new);


DESCRIPTION

This class provides a way to register classes/objects that track any commands executed anywhere in the program using run_tla and run_cmd of Arch::Util, including their output.

The observer classes/objects need to three or less methods: cmd_start, cmd_output_line, cmd_end. The observer should not implement all methods, but it makes sense to implement at least the first one.

cmd_start method is called with all command arguments as parameters, i.e. ($observer, ``tla'', ``archives'', ``-n'').

cmd_output_line method is called with command output line as parameter.

cmd_end is called without parameters.


FUNCTIONS

The following public functions are available:

observe, unobserve.

ArchWay::Util::RunCmd::observe observer
Receives an observer class name or object. It should implement some of the methods described above.

ArchWay::Util::RunCmd::unobserve observer
Stops notification of the given observer that should be the same one passed to observe.


BUGS

No known bugs.


AUTHORS

Mikhael Goikhman (migo@homemail.com--Perl-GPL/archway--devel)


SEE ALSO

For more information, see Arch::Util.