X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;ds=inline;f=vendor%2Fdrush%2Fdrush%2Fsrc%2FPsysh%2FDrushCommand.php;fp=vendor%2Fdrush%2Fdrush%2Fsrc%2FPsysh%2FDrushCommand.php;h=4172f5d9cd826ec32c8a909ef9123c7779b658b1;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hp=0000000000000000000000000000000000000000;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0;p=yaffs-website
diff --git a/vendor/drush/drush/src/Psysh/DrushCommand.php b/vendor/drush/drush/src/Psysh/DrushCommand.php
new file mode 100644
index 000000000..4172f5d9c
--- /dev/null
+++ b/vendor/drush/drush/src/Psysh/DrushCommand.php
@@ -0,0 +1,134 @@
+command = $command;
+ parent::__construct();
+ }
+
+ /**
+ * Get the namespace of this command.
+ */
+ public function getNamespace()
+ {
+ $parts = explode('-', $this->getName());
+ return count($parts) >= 2 ? array_shift($parts) : 'global';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function configure()
+ {
+ $this
+ ->setName($this->command->getName())
+ ->setAliases($this->command->getAliases())
+ ->setDefinition($this->command->getDefinition())
+ ->setDescription($this->command->getDescription())
+ ->setHelp($this->buildHelpFromCommand());
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $args = $input->getArguments();
+ $first = array_shift($args);
+
+ // If the first argument is an alias, assign the next argument as the
+ // command.
+ if (strpos($first, '@') === 0) {
+ $alias = $first;
+ $command = array_shift($args);
+ } // Otherwise, default the alias to '@self' and use the first argument as the
+ // command.
+ else {
+ $alias = '@self';
+ $command = $first;
+ }
+
+ $options = $input->getOptions();
+ // Force the 'backend' option to TRUE.
+ $options['backend'] = true;
+
+ $return = drush_invoke_process($alias, $command, array_values($args), $options, ['interactive' => true]);
+
+ if ($return['error_status'] > 0) {
+ foreach ($return['error_log'] as $error_type => $errors) {
+ $output->write($errors);
+ }
+ // Add a newline after so the shell returns on a new line.
+ $output->writeln('');
+ } else {
+ $output->page(drush_backend_get_result());
+ }
+ }
+
+ /**
+ * Build a command help from the Drush configuration array.
+ *
+ * Currently it's a word-wrapped description, plus any examples provided.
+ *
+ * @return string
+ * The help string.
+ */
+ protected function buildHelpFromCommand()
+ {
+ $help = wordwrap($this->command->getDescription());
+
+ $examples = [];
+ foreach ($this->command->getExampleUsages() as $ex => $def) {
+ // Skip empty examples and things with obvious pipes...
+ if (($ex === '') || (strpos($ex, '|') !== false)) {
+ continue;
+ }
+
+ $ex = preg_replace('/^drush\s+/', '', $ex);
+ $examples[$ex] = $def;
+ }
+
+ if (!empty($examples)) {
+ $help .= "\n\ne.g.";
+
+ foreach ($examples as $ex => $def) {
+ $help .= sprintf("\n// %s\n", wordwrap(OutputFormatter::escape($def), 75, "\n// "));
+ $help .= sprintf(">>> %s\n", OutputFormatter::escape($ex));
+ }
+ }
+
+ return $help;
+ }
+}