ソースを参照

Add docs for exec command, refs #4887

Jordi Boggiano 9 年 前
コミット
35d26db704
2 ファイル変更17 行追加7 行削除
  1. 10 0
      doc/03-cli.md
  2. 7 7
      src/Composer/Command/ExecCommand.php

+ 10 - 0
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

+ 7 - 7
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 <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);
         }