MooseX::Role::Cmd - Wrap system command binaries the Moose way
Create your command wrapper:
package Cmd::Perl; use strict; use warnings; use Moose; with 'MooseX::Role::Cmd'; has 'e' => (isa => 'Str', is => 'rw'); # other perl switches here... 1;
Use it somewhere else:
use Cmd::Perl; my $perl = Cmd::Perl->new(e => q{'print join ", ", @ARGV'}); print $perl->run(qw/foo bar baz/); # prints the STDOUT captured from running: # perl -e 'print join ", ", @ARGV' foo bar baz
MooseX::Role::Cmd is a Moose role intended to ease the task of building command-line wrapper modules. It automatically maps Moose objects into command strings which are passed to IPC::Cmd.
Sets the binary executable name for the command you want to run. Defaults the to last part of the class name.
Returns the STDOUT buffer captured after running the command.
Returns the STDERR buffer captured after running the command.
Builds the default string for the command name based on the class name.
Builds the command string and runs it based on the objects current attribute settings. This will treat all the attributes defined in your class as flags to be passed to the command.
Suppose the following setup:
has 'in' => (isa => 'Str', is => 'rw') has 'out' => (isa => 'Str', is => 'rw'); # ... $cmd->in('foo'); $cmd->out('bar');
The command will be invoked as:
cmd -in foo -out bar
All quoting issues are left to be solved by the user.
Eden Cardim <edencardim@gmail.com>
This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
To install MooseX::Role::Cmd, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::Role::Cmd
CPAN shell
perl -MCPAN -e shell install MooseX::Role::Cmd
For more information on module installation, please visit the detailed CPAN module installation guide.