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


PHP Command::setDescription方法代码示例

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


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

示例1: setDescription

 /**
  * @param string $desc
  * @return static
  */
 public function setDescription($desc)
 {
     if ($this instanceof IMightLoseData) {
         $desc .= ' <comment>(loses current data)</comment>';
     }
     return parent::setDescription($desc);
 }
开发者ID:VasekPurchart,项目名称:khanovaskola-v3,代码行数:11,代码来源:Command.php

示例2: __construct

 /**
  * Set up the command settings
  *
  * @return void
  * @author Dan Cox
  */
 public function __construct()
 {
     // Set the name and description
     parent::__construct($this->name);
     parent::setDescription($this->description);
     // Run the setup method for everything else
     $this->setup();
 }
开发者ID:danzabar,项目名称:alice,代码行数:14,代码来源:BaseCommand.php

示例3: generateCommand

 /**
  * creates a Command based on an Api Method.
  *
  * @param string            $name
  * @param \ReflectionMethod $method
  * @param string            $token
  *
  * @return Command
  */
 private function generateCommand($name, \ReflectionMethod $method, $token = null)
 {
     $methodName = $this->transformer->transform($method->getName());
     $command = new Command(strtolower($name . ':' . $methodName));
     $docBlock = DocBlockFactory::createInstance()->create($method->getDocComment());
     $command->setDefinition($this->buildDefinition($method, $token));
     $command->setDescription($docBlock->getSummary());
     $command->setCode($this->createCode($name, $method));
     return $command;
 }
开发者ID:digitalkaoz,项目名称:versioneye-php,代码行数:19,代码来源:CommandFactory.php

示例4: addInitRoboFileCommand

 public function addInitRoboFileCommand($roboFile, $roboClass)
 {
     $createRoboFile = new Command('init');
     $createRoboFile->setDescription("Intitalizes basic RoboFile in current dir");
     $createRoboFile->setCode(function () use($roboClass, $roboFile) {
         $output = Config::get('output');
         $output->writeln("<comment>  ~~~ Welcome to Robo! ~~~~ </comment>");
         $output->writeln("<comment>  " . $roboFile . " will be created in current dir </comment>");
         file_put_contents($roboFile, '<?php' . "\n/**" . "\n * This is project's console commands configuration for Robo task runner." . "\n *" . "\n * @see http://robo.li/" . "\n */" . "\nclass " . $roboClass . " extends \\Robo\\Tasks\n{\n    // define public methods as commands\n}");
         $output->writeln("<comment>  Edit RoboFile.php to add your commands! </comment>");
     });
     $this->add($createRoboFile);
 }
开发者ID:stefanhuber,项目名称:Robo,代码行数:13,代码来源:Application.php

示例5: buildCommand

 /**
  * Build a Symfony Console commands.
  *
  * @param \Yosymfony\Spress\Plugin\CommandPluginInterface $commandPlugin
  *
  * @return \Symfony\Component\Console\Command\Command Symfony Console command.
  */
 protected function buildCommand(CommandPluginInterface $commandPlugin)
 {
     $definition = $commandPlugin->getCommandDefinition();
     $argumentsAndOptions = [];
     $consoleComand = new Command($definition->getName());
     $consoleComand->setDescription($definition->getDescription());
     $consoleComand->setHelp($definition->getHelp());
     foreach ($definition->getArguments() as list($name, $mode, $description, $defaultValue)) {
         $argumentsAndOptions[] = new InputArgument($name, $mode, $description, $defaultValue);
     }
     foreach ($definition->getOptions() as list($name, $shortcut, $mode, $description, $defaultValue)) {
         $argumentsAndOptions[] = new InputOption($name, $shortcut, $mode, $description, $defaultValue);
     }
     $consoleComand->setDefinition($argumentsAndOptions);
     $consoleComand->setCode(function (InputInterface $input, OutputInterface $output) use($commandPlugin) {
         $io = new ConsoleIO($input, $output);
         $arguments = $input->getArguments();
         $options = $input->getOptions();
         $commandPlugin->executeCommand($io, $arguments, $options);
     });
     return $consoleComand;
 }
开发者ID:jjk-jacky,项目名称:Spress,代码行数:29,代码来源:ConsoleCommandBuilder.php

示例6: setDescription

 /**
  * {@inheritdoc}
  */
 public function setDescription($description)
 {
     $this->decoratedCommand->setDescription($description);
     return $this;
 }
开发者ID:frankdejonge,项目名称:locked-console-command,代码行数:8,代码来源:LockedCommandDecorator.php

示例7: createCommand

 /**
  * @param $className
  * @param TaskInfo $taskInfo
  * @return Command
  */
 protected function createCommand($className, TaskInfo $taskInfo)
 {
     if ($className === strtolower(Tg::TGCLASS)) {
         $name = $taskInfo->getName();
     } else {
         $camel = preg_replace("/:/", '-', $taskInfo->getName());
         $name = $className . ':' . $camel;
     }
     $task = new Command($name);
     $task->setDescription($taskInfo->getDescription());
     $task->setHelp($taskInfo->getHelp());
     $args = $taskInfo->getArguments();
     foreach ($args as $name => $val) {
         $description = $taskInfo->getArgumentDescription($name);
         if ($val === TaskInfo::PARAM_IS_REQUIRED) {
             $task->addArgument($name, InputArgument::REQUIRED, $description);
         } elseif (is_array($val)) {
             $task->addArgument($name, InputArgument::IS_ARRAY, $description, $val);
         } else {
             $task->addArgument($name, InputArgument::OPTIONAL, $description, $val);
         }
     }
     $opts = $taskInfo->getOptions();
     foreach ($opts as $name => $val) {
         $description = $taskInfo->getOptionDescription($name);
         $fullName = $name;
         $shortcut = '';
         if (strpos($name, '|')) {
             list($fullName, $shortcut) = explode('|', $name, 2);
         }
         if (is_bool($val)) {
             $task->addOption($fullName, $shortcut, InputOption::VALUE_NONE, $description);
         } else {
             $task->addOption($fullName, $shortcut, InputOption::VALUE_OPTIONAL, $description, $val);
         }
     }
     return $task;
 }
开发者ID:twhiston,项目名称:tg,代码行数:43,代码来源:CommandLoader.php

示例8: setDescription

 public function setDescription($description)
 {
     return $this->innerCommand->setDescription($description);
 }
开发者ID:lolautruche,项目名称:ezsh,代码行数:4,代码来源:WrappedCommand.php

示例9: createCommand

 public function createCommand(TaskInfo $taskInfo)
 {
     $task = new Command($taskInfo->getName());
     $task->setDescription($taskInfo->getDescription());
     $task->setHelp($taskInfo->getHelp());
     $args = $taskInfo->getArguments();
     foreach ($args as $name => $val) {
         $description = $taskInfo->getArgumentDescription($name);
         if ($val === TaskInfo::PARAM_IS_REQUIRED) {
             $task->addArgument($name, InputArgument::REQUIRED, $description);
         } elseif (is_array($val)) {
             $task->addArgument($name, InputArgument::IS_ARRAY, $description, $val);
         } else {
             $task->addArgument($name, InputArgument::OPTIONAL, $description, $val);
         }
     }
     $opts = $taskInfo->getOptions();
     foreach ($opts as $name => $val) {
         $description = $taskInfo->getOptionDescription($name);
         $fullname = $name;
         $shortcut = '';
         if (strpos($name, '|')) {
             list($fullname, $shortcut) = explode('|', $name, 2);
         }
         if (is_bool($val)) {
             $task->addOption($fullname, $shortcut, InputOption::VALUE_NONE, $description);
         } else {
             $task->addOption($fullname, $shortcut, InputOption::VALUE_OPTIONAL, $description, $val);
         }
     }
     return $task;
 }
开发者ID:roland-d,项目名称:Robo,代码行数:32,代码来源:Runner.php

示例10: configure

 /**
  * Configures a console command by setting name, description, arguments, etc.
  *
  * @param Command $command
  */
 public static function configure(Command $command)
 {
     $command->setName('config:status');
     $command->setAliases(['status']);
     $command->setDescription('Shows the current migration status.');
 }
开发者ID:baleen,项目名称:cli,代码行数:11,代码来源:StatusMessage.php

示例11: getDescription

 /**
  * Get the description
  *
  * @return string
  */
 public function getDescription()
 {
     $description = parent::getDescription();
     if ($description === null) {
         $descriptor = new Descriptor();
         $description = (string) $descriptor->describeTask($this->getJob());
         parent::setDescription($description);
     }
     return $description;
 }
开发者ID:netresearch,项目名称:kite,代码行数:15,代码来源:JobCommand.php

示例12: addCommand

 /**
  * Registers a command.
  * 
  * @param string $name Name of the command.
  * @param string $commandClass Class name of the command.
  */
 public function addCommand($name, $commandClass)
 {
     // must extend AbstractCommand
     $abstractCommandClass = AbstractCommand::class;
     if (!Debugger::isExtending($commandClass, $abstractCommandClass)) {
         throw new InvalidCommandException('Command "' . $commandClass . '" must extend "' . $abstractCommandClass . '".');
     }
     // name cannot be empty
     $name = trim($name);
     if (empty($name)) {
         throw new InvalidArgumentException('Command name cannot be empty for "' . $commandClass . '"!');
     }
     // configure the command
     $console = $this;
     $consoleCommand = new ConsoleCommand($name);
     $consoleCommand->setDescription($commandClass::getDescription());
     $consoleCommand->setHelp($commandClass::getHelp());
     $consoleCommand->setCode(function (InputInterface $input, OutputInterface $output) use($console, $name) {
         $console->exec($name, $input, $output);
     });
     // read some meta info about the command
     $commandReflection = new \ReflectionClass($commandClass);
     $arguments = array();
     $argumentsDescriptions = $commandClass::getArguments();
     try {
         $methodReflection = $commandReflection->getMethod('execute');
         if (!$methodReflection->isPublic() || $methodReflection->isStatic()) {
             throw new InvalidCommandException('The "execute()" method for ommand "' . $commandClass . '" must be public and non-static.');
         }
         // get the execute() method's arguments so we can translate them to CLI arguments
         $parametersReflection = $methodReflection->getParameters();
         foreach ($parametersReflection as $param) {
             $optional = $param->isDefaultValueAvailable();
             $paramName = $param->getName();
             $arguments[] = array('name' => $paramName, 'optional' => $optional, 'default' => $optional ? $param->getDefaultValue() : null, 'description' => isset($argumentsDescriptions[$paramName]) ? $argumentsDescriptions[$paramName] : '');
         }
     } catch (\ReflectionException $e) {
         throw new InvalidCommandException('Command "' . $commandClass . '" must implement public function "execute()"!');
     }
     foreach ($arguments as $argument) {
         $consoleCommand->addArgument($argument['name'], $argument['optional'] ? InputArgument::OPTIONAL : InputArgument::REQUIRED, $argument['description'], $argument['default']);
     }
     // also register command's options
     $options = $commandClass::getOptions();
     foreach ($options as $option => $optionInfo) {
         $value = isset($optionInfo['required']) && $optionInfo['required'] ? InputOption::VALUE_REQUIRED : (!isset($optionInfo['default']) || empty($optionInfo['default']) || $optionInfo['default'] === null ? InputOption::VALUE_NONE : InputOption::VALUE_OPTIONAL);
         $consoleCommand->addOption($option, isset($optionInfo['shortcut']) ? $optionInfo['shortcut'] : null, $value, isset($optionInfo['description']) ? $optionInfo['description'] : '', $value === InputOption::VALUE_REQUIRED || $value === InputOption::VALUE_NONE ? null : (isset($optionInfo['default']) ? $optionInfo['default'] : null));
     }
     // register the command
     $this->commands[$name] = array('name' => $name, 'class' => $commandClass, 'command' => $consoleCommand, 'arguments' => $arguments, 'options' => $options);
     $this->consoleApplication->add($consoleCommand);
 }
开发者ID:splot,项目名称:framework,代码行数:58,代码来源:Console.php

示例13: createCommand

 protected function createCommand($taskName)
 {
     $taskInfo = new TaskInfo(self::ROBOCLASS, $taskName);
     $task = new Command($taskInfo->getName());
     $task->setDescription($taskInfo->getDescription());
     $args = $taskInfo->getArguments();
     foreach ($args as $name => $val) {
         if ($val === TaskInfo::PARAM_IS_REQUIRED) {
             $task->addArgument($name, InputArgument::REQUIRED);
         } elseif (is_array($val)) {
             $task->addArgument($name, InputArgument::IS_ARRAY, '', $val);
         } else {
             $task->addArgument($name, InputArgument::OPTIONAL, '', $val);
         }
     }
     $opts = $taskInfo->getOptions();
     foreach ($opts as $name => $val) {
         if (empty($val)) {
             $task->addOption($name, '', InputOption::VALUE_NONE, '');
         } else {
             $task->addOption($name, '', InputOption::VALUE_OPTIONAL, '', $val);
         }
     }
     return $task;
 }
开发者ID:sliver,项目名称:Robo,代码行数:25,代码来源:Runner.php

示例14: Command

                $output->writeLn(sprintf('Parsed city <info>%s</info> in country <info>%s</info> in zone <info>%s</info>', $data['FIELD2'], $data['FIELD9'], $data['FIELD18']));
            } else {
                $output->write('.');
            }
        });
    });
    # parse data and load into table
    $parser->parse(__DIR__ . '/cities15000.csv', $parser_options);
    $output->writeLn('Finished <info>parsing names</info> into database');
});
//---------------------------------------------------------------------
// Parse Countries csv
//
//--------------------------------------------------------------------
$parse_countries = new Command('countries');
$parse_countries->setDescription('Parse Csv of countries into the local sqlite db');
$parse_countries->setCode(function (InputInterface $input, ConsoleOutputInterface $output) use($project) {
    $output->writeLn('Starting Parse of Country this may <info>take a while</info>');
    # create a csv parser
    $parser = $project['parser'];
    $parser_options = $project['parser_options'];
    $parser_options->setParser('csv');
    $parser_options->setHasHeaderRow(false);
    $parser_options->setFieldSeperator(59);
    $parser_options->setSkipRows(0);
    # register for the generate event
    $event = $project['event_dispatcher'];
    $connection = $project['faker_database'];
    $event->addListener('row_parsed', function (Faker\Parser\Event\RowParsed $event) use($connection, $output, $input) {
        /* Example of data from names file
           Array
开发者ID:icomefromthenet,项目名称:faker,代码行数:31,代码来源:build.php

示例15: configure

 /**
  * @inheritdoc
  */
 public static function configure(Command $command)
 {
     $command->setName('config:init');
     $command->setAliases(['init']);
     $command->setDescription('Initialises Baleen by creating a config file in the current directory.');
 }
开发者ID:baleen,项目名称:cli,代码行数:9,代码来源:InitMessage.php


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