DESCRIPTION

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.

ATTRIBUTES

$cmd->bin_name

Sets the binary executable name for the command you want to run. Defaults the to last part of the class name.

$cmd->stdout

Returns the STDOUT buffer captured after running the command.

$cmd->stderr

Returns the STDERR buffer captured after running the command.

METHODS

$bin_name = $cmd->build_bin_name

Builds the default string for the command name based on the class name.

@stdout = $cmd->run(@args);

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.

NOTE: All quoting issues are left to be solved by the user.

cmd_args

Returns a list of the computed arguments that will be added to the command

ADDITIONAL INFORMATION

Setting the Executable

By default the name of the binary executable is taken from the last part of the class name (in lower case). The path is set during the run method by scanning through your current PATH for the given executable (see also the 'can_run' function from IPC::Cmd)

How attributes are mapped to parameters

The attributes of the consuming package map directly to the parameters passed to the executable. There are a few things to note about the default behaviour governing the way these attributes are mapped.

Changing names of parameters

It's possible that the parameters your system command expects do not adhere to this naming scheme. In this case you can use the 'CmdOpt' trait which allows you to specify exactly how you want the parameter to appear on the command line.

has 'option' => ( isa => 'Bool' );
# --option

cmdopt_prefix

This lets you override the prefix used for the option (for example to use the short form of multi-character options).