Help language development. Donate to The Perl Foundation
Proc::Easier - run processes with OO goodness
use Proc::Easier; # run a command cmd('ls'); # run command and assign resultant Proc::Easier object to a scalar my $cmd = cmd('ls'); # get info about the object say $cmd.out; say $cmd.err; say $cmd.exit; # exitcode # dump info about the command for debugging say $cmd; # run a command, say its output say cmd('ls').out; # run a command, say its error say cmd('ls').err; # run a command from a different directory cmd('ls', '/home/dir'); # run a command, die if error encountered, then print info cmd('a-bad-command', :die); # make :die the default for all commands until its turned off autodie(:on); cmd('kjkjsdkjf'); # this dies # turn off :die until its turned back on autodie(:off); cmd('kjkjsdkjf'); # this doesn't die # create a command with standard OO, don't run it immediately my $cmd= Proc::Easier.new(cmd => 'ls', :lazy); # run the command $cmd.run;
Proc::Easier is a convenient wrapper for the
run command using a OO interface to make issuing commands from Raku much easier.
cmd('ls', '/some/dir', :die);
Convenience method for constructing a
Proc::Easier object. Accepts a command, an optional directory command to run the command from, an an option to die if an error is encountered, and an optoin to make the command "lazy." Lazy commands will not be executed unless the run method is called on the object. Otherwise, oonce the object is constructed, the command will be immediately executed.
Turns on/off the autodie switch. All subsequent
Proc::Easier commands will behave as if the
:die feature has been turned on or off. Default is off.
Accepts the same four named variables as the
cmd convenience method.
Runs the command.
Returns the string from stdout, if any.
Returns the string from stderr, if any.
Returns the exit code from the shell, '0' indicates success, other numbers indicate an error.
Returns the name of the file where the call was made.
Returns the line number of the file where the call was made.
Contains the original command.
The directory where the command will be execute.
Whether the command will die if an error is encountered.
Steve Dondley [email protected]
Thanks to tbrowder for the
Proc::Easy distribution which shamelessly inspired the name of this module and furnished some code and ideas to recycle, too.
Copyright 2022 Steve Dondley
This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.