From 35d26db7041fdfe28ceca64e775736c47d7b2e0d Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 25 Feb 2016 12:21:30 +0000 Subject: [PATCH] Add docs for exec command, refs #4887 --- doc/03-cli.md | 10 ++++++++++ src/Composer/Command/ExecCommand.php | 14 +++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/doc/03-cli.md b/doc/03-cli.md index b5714d442..ec2b6dd62 100644 --- a/doc/03-cli.md +++ b/doc/03-cli.md @@ -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 diff --git a/src/Composer/Command/ExecCommand.php b/src/Composer/Command/ExecCommand.php index 3dc669d38..0938f6659 100644 --- a/src/Composer/Command/ExecCommand.php +++ b/src/Composer/Command/ExecCommand.php @@ -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 -- to separate from composer arguments' + 'Arguments to pass to the binary. Use -- 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(<<Available scripts: +Available binaries: 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); }