Browse Source

WIP show commands.

Frederic G. MARAND 4 years ago
parent
commit
a7b8a46669
1 changed files with 24 additions and 0 deletions
  1. 24 0
      src/Builder.php

+ 24 - 0
src/Builder.php

@@ -80,6 +80,25 @@ class Builder implements Capable, Capability, EventSubscriberInterface, PluginIn
     ];
   }
 
+  protected function showCommands() {
+    $capabilities = $this->getCapabilities();
+    if (empty($capabilities[CommandProvider::class])) {
+      return;
+    }
+    $providerClass = $capabilities[CommandProvider::class];
+    /** @var \Composer\Plugin\Capability\CommandProvider $provider */
+    $provider = new $providerClass([
+      'composer' => $this->composer,
+      'io' => $io = $this->io,
+      'plugin' => NULL,
+    ]);
+    $commands = $provider->getCommands();
+    $io->write("Available build commands:");
+    foreach ($commands as $command) {
+      $io->write("- " . $command->getName());
+    }
+  }
+
   /**
    * Event callback: run build:settings  on post-install|update only.
    *
@@ -96,6 +115,11 @@ class Builder implements Capable, Capability, EventSubscriberInterface, PluginIn
       // FIXME without an argument, the command should build all templates.
       // $buildCommand = new BuildSettingsCommand($event->getName());
       // $buildCommand->run(new ArgvInput([]), new ConsoleOutput());
+
+      // Verbosity seems limited to 32, while the test expects 64 or 128.
+      if ($event->getIO()->isVerbose()) {
+        $this->showCommands();
+      }
     }
   }