当前位置: 首页>>代码示例>>PHP>>正文


PHP ApplicationDescription::getCommand方法代码示例

本文整理汇总了PHP中Symfony\Component\Console\Descriptor\ApplicationDescription::getCommand方法的典型用法代码示例。如果您正苦于以下问题:PHP ApplicationDescription::getCommand方法的具体用法?PHP ApplicationDescription::getCommand怎么用?PHP ApplicationDescription::getCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Console\Descriptor\ApplicationDescription的用法示例。


在下文中一共展示了ApplicationDescription::getCommand方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: describeApplication

 /**
  * @inheritdoc
  */
 protected function describeApplication(ConsoleApplication $application, array $options = array())
 {
     $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
     $description = new ApplicationDescription($application, $describedNamespace);
     if (isset($options['raw_text']) && $options['raw_text']) {
         $width = $this->getColumnWidth($description->getCommands());
         foreach ($description->getCommands() as $command) {
             $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options);
             $this->writeText("\n");
         }
     } else {
         $width = $this->getColumnWidth($description->getCommands());
         $this->writeText($application->getHelp(), $options);
         $this->writeText("\n\n");
         if ($describedNamespace) {
             $this->writeText(sprintf("<comment>Available commands for the \"%s\" namespace:</comment>", $describedNamespace), $options);
         } else {
             $this->writeText('<comment>Available commands:</comment>', $options);
         }
         // add commands by namespace
         foreach ($description->getNamespaces() as $namespace) {
             if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
                 $this->writeText("\n");
                 $this->writeText('<comment>' . $namespace['id'] . '</comment>', $options);
             }
             foreach ($namespace['commands'] as $name) {
                 $command = $description->getCommand($name);
                 $aliases = $command->getAliases();
                 if ($aliases && ApplicationDescription::GLOBAL_NAMESPACE === $namespace['id'] && in_array($name, $aliases)) {
                     // If the command has aliases, do not list it in the
                     // 'global' namespace. The aliases will be shown inline
                     // with the full command name.
                     continue;
                 }
                 // Colour local commands differently from remote ones.
                 $commandDescription = $command->getDescription();
                 if ($command instanceof PlatformCommand && !$command->isLocal()) {
                     $commandDescription = "<fg=cyan>{$commandDescription}</fg=cyan>";
                 }
                 $this->writeText("\n");
                 $this->writeText(sprintf("  %-{$width}s %s", "<info>{$name}</info>" . $this->formatAliases($aliases), $commandDescription), $options);
             }
         }
         $this->writeText("\n");
     }
 }
开发者ID:ratajczak,项目名称:platformsh-cli,代码行数:49,代码来源:CustomTextDescriptor.php

示例2: describeApplication

 /**
  * {@inheritdoc}
  */
 protected function describeApplication(Application $application, array $options = [])
 {
     $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
     $description = new ApplicationDescription($application, $describedNamespace);
     if (isset($options['raw_text']) && $options['raw_text']) {
         $width = $this->getColumnWidth($description->getCommands());
         foreach ($description->getCommands() as $command) {
             $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options);
             $this->writeText("\n");
         }
     } else {
         if ('' != ($help = $application->getHelp())) {
             $this->writeText("{$help}\n\n", $options);
         }
         $this->writeText("<comment>Usage:</comment>\n", $options);
         $this->writeText("  command [options] [arguments]\n\n", $options);
         $this->describeInputDefinition(new InputDefinition($application->getDefinition()->getOptions()), $options);
         $this->writeText("\n");
         $this->writeText("\n");
         $width = $this->getColumnWidth($description->getCommands());
         if ($describedNamespace) {
             $this->writeText(sprintf('<comment>Available commands for the "%s" namespace:</comment>', $describedNamespace), $options);
         } else {
             $this->writeText('<comment>Available commands:</comment>', $options);
         }
         // add commands by namespace
         foreach ($description->getNamespaces() as $namespace) {
             if ($this->shouldListCommand($namespace['id']) === false) {
                 continue;
             }
             if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
                 $this->writeText("\n");
                 $this->writeText(' <comment>' . $namespace['id'] . '</comment>', $options);
             }
             foreach ($namespace['commands'] as $name) {
                 if ($this->shouldListCommand($namespace['id'], $name) === false) {
                     continue;
                 }
                 $this->writeText("\n");
                 $spacingWidth = $width - strlen($name);
                 $this->writeText(sprintf('  <info>%s</info>%s%s', $name, str_repeat(' ', $spacingWidth), $description->getCommand($name)->getDescription()), $options);
             }
         }
         $this->writeText("\n");
     }
 }
开发者ID:codex-project,项目名称:develop,代码行数:49,代码来源:TextDescriptor.php

示例3: describeApplication

 /**
  * {@inheritdoc}
  */
 protected function describeApplication(Application $application, array $options = array())
 {
     $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
     $description = new ApplicationDescription($application, $describedNamespace);
     if (isset($options['raw_text']) && $options['raw_text']) {
         $width = $this->getColumnWidth($description->getCommands());
         foreach ($description->getCommands() as $command) {
             $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options);
             $this->writeText("\n");
         }
     } else {
         if ('' != ($help = $application->getHelp())) {
             $this->writeText("{$help}\n\n", $options);
         }
         $this->describeInputDefinition(new InputDefinition($application->getDefinition()->getOptions()), $options);
         $this->writeText("\n");
         $this->writeText("\n");
         $width = $this->getColumnWidth($description->getCommands());
         if ($describedNamespace) {
             $this->writeText(sprintf('<comment>Available commands for the "%s" namespace:</comment>', $describedNamespace), $options);
         } else {
             $this->writeText('<comment>Available commands:</comment>', $options);
         }
         // add commands by namespace
         foreach ($description->getNamespaces() as $namespace) {
             if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
                 $this->writeText("\n");
                 $this->writeText(' <comment>' . $namespace['id'] . '</comment>', $options);
             }
             foreach ($namespace['commands'] as $name) {
                 $command = $description->getCommand($name);
                 $aliases = $command->getAliases();
                 if ($aliases && in_array($name, $aliases)) {
                     // skip aliases
                     continue;
                 }
                 $this->writeText("\n");
                 $this->writeText(sprintf("  %-{$width}s %s", "<info>{$name}</info>" . $this->formatAliases($aliases), $command->getDescription()), $options);
             }
         }
         $this->writeText("\n");
     }
 }
开发者ID:mglaman,项目名称:drupalorg-cli,代码行数:46,代码来源:CustomTextDescriptor.php

示例4: describeApplication

 /**
  * {@inheritdoc}
  */
 protected function describeApplication(Application $application, array $options = array())
 {
     $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
     $description = new ApplicationDescription($application, $describedNamespace);
     if (isset($options['raw_text']) && $options['raw_text']) {
         $width = $this->getColumnWidth($description->getCommands());
         foreach ($description->getCommands() as $command) {
             $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options);
             $this->writeText("\n");
         }
     } else {
         if ('' != ($help = $application->getHelp())) {
             $this->writeText("{$help}\n\n", $options);
         }
         $this->writeText($application->trans('commands.list.messages.usage'), $options);
         $this->writeText($application->trans('commands.list.messages.usage_details'), $options);
         $options['application'] = $application;
         $this->describeInputDefinition(new InputDefinition($application->getDefinition()->getOptions()), $options);
         $this->writeText("\n");
         $this->writeText("\n");
         $width = $this->getColumnWidth($description->getCommands());
         if ($describedNamespace) {
             $this->writeText(sprintf($application->trans('commands.list.messages.comment'), $describedNamespace), $options);
         } else {
             $this->writeText($application->trans('commands.list.messages.available-commands'), $options);
         }
         // add commands by namespace
         foreach ($description->getNamespaces() as $namespace) {
             if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
                 $this->writeText("\n");
                 $this->writeText(' <comment>' . $namespace['id'] . '</comment>', $options);
             }
             foreach ($namespace['commands'] as $name) {
                 $this->writeText("\n");
                 $spacingWidth = $width - strlen($name);
                 $this->writeText(sprintf('  <info>%s</info>%s%s', $name, str_repeat(' ', $spacingWidth), $description->getCommand($name)->getDescription()), $options);
             }
         }
         $this->writeText("\n");
     }
 }
开发者ID:legovaer,项目名称:DrupalConsole,代码行数:44,代码来源:TextDescriptor.php

示例5: describeApplication

 /**
  * {@inheritdoc}
  */
 protected function describeApplication(Application $application, array $options = array())
 {
     $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
     $description = new ApplicationDescription($application, $describedNamespace);
     if (isset($options['raw_text']) && $options['raw_text']) {
         $width = $this->getColumnWidth($description->getCommands());
         foreach ($description->getCommands() as $command) {
             $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options);
             $this->writeText("\n");
         }
     } else {
         if ('' != ($help = $application->getHelp())) {
             $this->writeText("{$help}\n\n", $options);
         }
         $this->writeText("<comment>Usage:</comment>\n", $options);
         $this->writeText(" [options] command [arguments]\n\n", $options);
         $this->writeText('<comment>Options:</comment>', $options);
         $inputOptions = $application->getDefinition()->getOptions();
         $width = 0;
         foreach ($inputOptions as $option) {
             $nameLength = strlen($option->getName()) + 2;
             if ($option->getShortcut()) {
                 $nameLength += strlen($option->getShortcut()) + 3;
             }
             $width = max($width, $nameLength);
         }
         ++$width;
         foreach ($inputOptions as $option) {
             $this->writeText("\n", $options);
             $this->describeInputOption($option, array_merge($options, array('name_width' => $width)));
         }
         $this->writeText("\n\n", $options);
         $width = $this->getColumnWidth($description->getCommands());
         if ($describedNamespace) {
             $this->writeText(sprintf("<comment>Available commands for the \"%s\" namespace:</comment>", $describedNamespace), $options);
         } else {
             $this->writeText('<comment>Available commands:</comment>', $options);
         }
         // add commands by namespace
         foreach ($description->getNamespaces() as $namespace) {
             if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
                 $this->writeText("\n");
                 $this->writeText('<comment>' . $namespace['id'] . '</comment>', $options);
             }
             foreach ($namespace['commands'] as $name) {
                 $this->writeText("\n");
                 $this->writeText(sprintf(" <info>%-{$width}s</info> %s", $name, $description->getCommand($name)->getDescription()), $options);
             }
         }
         $this->writeText("\n");
     }
 }
开发者ID:EnmanuelCode,项目名称:backend-laravel,代码行数:55,代码来源:TextDescriptor.php

示例6: describeApplication

 /**
  * {@inheritdoc}
  */
 protected function describeApplication(Application $application, array $options = array())
 {
     $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
     $description = new ApplicationDescription($application, $describedNamespace);
     if (isset($options['raw_text']) && $options['raw_text']) {
         $width = $this->getColumnWidth($description->getCommands());
         foreach ($description->getCommands() as $command) {
             $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options);
             $this->writeText("\n");
         }
     } else {
         $width = $this->getColumnWidth($description->getCommands());
         $this->writeText($application->getHelp(), $options);
         $this->writeText("\n\n");
         if ($describedNamespace) {
             $this->writeText(sprintf("<comment>Available commands for the \"%s\" namespace:</comment>", $describedNamespace), $options);
         } else {
             $this->writeText('<comment>Available commands:</comment>', $options);
         }
         // add commands by namespace
         foreach ($description->getNamespaces() as $namespace) {
             if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
                 $this->writeText("\n");
                 $this->writeText('<comment>' . $namespace['id'] . '</comment>', $options);
             }
             foreach ($namespace['commands'] as $name) {
                 $this->writeText("\n");
                 $this->writeText(sprintf("  <info>%-{$width}s</info> %s", $name, $description->getCommand($name)->getDescription()), $options);
             }
         }
         $this->writeText("\n");
     }
 }
开发者ID:GeorgeBroadley,项目名称:caffeine-vendor,代码行数:36,代码来源:TextDescriptor.php

示例7: describeApplication

 /**
  * @inheritdoc
  */
 protected function describeApplication(ConsoleApplication $application, array $options = [])
 {
     $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
     $description = new ApplicationDescription($application, $describedNamespace);
     if (isset($options['raw_text']) && $options['raw_text']) {
         $width = $this->getColumnWidth($description->getCommands());
         foreach ($description->getCommands() as $command) {
             $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options);
             $this->writeText("\n");
         }
     } else {
         $width = $this->getColumnWidth($description->getCommands());
         $this->writeText($application->getHelp(), $options);
         $this->writeText("\n\n");
         if ($describedNamespace) {
             $this->writeText(sprintf("<comment>Available commands for the \"%s\" namespace:</comment>", $describedNamespace), $options);
         } else {
             $this->writeText('<comment>Available commands:</comment>', $options);
         }
         // Display commands grouped by namespace.
         foreach ($description->getNamespaces() as $namespace) {
             // Filter hidden commands in the namespace.
             /** @var Command[] $commands */
             $commands = [];
             foreach ($namespace['commands'] as $name) {
                 $command = $description->getCommand($name);
                 if (!$describedNamespace && $command instanceof CanHideInListInterface && $command->hideInList()) {
                     continue;
                 }
                 $commands[$name] = $command;
             }
             // Skip the namespace if it doesn't contain any commands.
             if (!count($commands)) {
                 continue;
             }
             // Display the namespace name.
             if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
                 $this->writeText("\n");
                 $this->writeText('<comment>' . $namespace['id'] . '</comment>', $options);
             }
             // Display each command.
             foreach ($commands as $name => $command) {
                 $aliases = $command->getAliases();
                 if ($aliases && in_array($name, $aliases)) {
                     // If the command is an alias, do not list it in the
                     // 'global' namespace. The aliases will be shown inline
                     // with the full command name.
                     continue;
                 }
                 if ($command instanceof CommandBase) {
                     $aliases = $command->getVisibleAliases();
                 }
                 // Colour local commands differently from remote ones.
                 $commandDescription = $command->getDescription();
                 if ($command instanceof CommandBase && !$command->isLocal()) {
                     $commandDescription = "<fg=cyan>{$commandDescription}</fg=cyan>";
                 }
                 $this->writeText("\n");
                 $this->writeText(sprintf("  %-{$width}s %s", "<info>{$name}</info>" . $this->formatAliases($aliases), $commandDescription), $options);
             }
         }
         $this->writeText("\n");
     }
 }
开发者ID:drewmelck,项目名称:platformsh-cli,代码行数:67,代码来源:CustomTextDescriptor.php


注:本文中的Symfony\Component\Console\Descriptor\ApplicationDescription::getCommand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。