Add docs for exec command, refs #4887
parent
934be204a2
commit
35d26db704
|
@ -602,6 +602,16 @@ Lists the name, version and license of every package installed. Use
|
|||
To run [scripts](articles/scripts.md) manually you can use this command,
|
||||
just give it the script name and optionally any required arguments.
|
||||
|
||||
## exec
|
||||
|
||||
Executes a vendored binary/script. You can execute any command and this will
|
||||
ensure that the Composer bin-dir is pushed on your PATH before the command
|
||||
runs.
|
||||
|
||||
### Options
|
||||
|
||||
* **--list:** List the available composer binaries
|
||||
|
||||
## diagnose
|
||||
|
||||
If you think you found a bug, or something is behaving strangely, you might
|
||||
|
|
|
@ -29,11 +29,11 @@ class ExecCommand extends BaseCommand
|
|||
->setDescription('Execute a vendored binary/script')
|
||||
->setDefinition(array(
|
||||
new InputOption('list', 'l', InputOption::VALUE_NONE),
|
||||
new InputArgument('script', InputArgument::OPTIONAL, 'The script to run, e.g. phpunit'),
|
||||
new InputArgument('binary', InputArgument::OPTIONAL, 'The binary to run, e.g. phpunit'),
|
||||
new InputArgument(
|
||||
'args',
|
||||
InputArgument::IS_ARRAY | InputArgument::OPTIONAL,
|
||||
'Arguments to pass to the script. Use <info>--</info> to separate from composer arguments'
|
||||
'Arguments to pass to the binary. Use <info>--</info> to separate from composer arguments'
|
||||
),
|
||||
))
|
||||
;
|
||||
|
@ -43,15 +43,15 @@ class ExecCommand extends BaseCommand
|
|||
{
|
||||
$composer = $this->getComposer();
|
||||
$binDir = $composer->getConfig()->get('bin-dir');
|
||||
if ($input->getOption('list') || !$input->getArgument('script')) {
|
||||
if ($input->getOption('list') || !$input->getArgument('binary')) {
|
||||
$bins = glob($binDir . '/*');
|
||||
|
||||
if (!$bins) {
|
||||
throw new \RuntimeException("No scripts found in bin-dir ($binDir)");
|
||||
throw new \RuntimeException("No binaries found in bin-dir ($binDir)");
|
||||
}
|
||||
|
||||
$this->getIO()->write(<<<EOT
|
||||
<comment>Available scripts:</comment>
|
||||
<comment>Available binaries:</comment>
|
||||
EOT
|
||||
);
|
||||
|
||||
|
@ -72,10 +72,10 @@ EOT
|
|||
return;
|
||||
}
|
||||
|
||||
$script = $input->getArgument('script');
|
||||
$binary = $input->getArgument('binary');
|
||||
|
||||
$dispatcher = $composer->getEventDispatcher();
|
||||
$dispatcher->addListener('__exec_command', $script);
|
||||
$dispatcher->addListener('__exec_command', $binary);
|
||||
if ($output->getVerbosity() === OutputInterface::VERBOSITY_NORMAL) {
|
||||
$output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue