[李景山php]每天TP5-20161227|thinkphp5-Console.php-4
来源:互联网 发布:window c语言编译器 编辑:程序博客网 时间:2024/05/22 13:06
/** * 获取所有的指令 * @param string $namespace 命名空间 * @return Command[] * @api */ public function all($namespace = null) {// 获取全部指令 if (null === $namespace) { return $this->commands; }// 为空 就获取全部的指令 $commands = [];// 命令仓库 foreach ($this->commands as $name => $command) {// 遍历搜索仓库 if ($this->extractNamespace($name, substr_count($namespace, ':') + 1) === $namespace) {// 如果存在这个命令 $commands[$name] = $command;// 装入这个 仓库 } } return $commands;// 返回数据 } /** * 获取可能的指令名 * @param array $names * @return array */ public static function getAbbreviations($names) {// 获取 可能的 指令名 $abbrevs = [];//仓库 foreach ($names as $name) {// 遍历循环 for ($len = strlen($name); $len > 0; --$len) {// 不断递减的 指令名称 $abbrev = substr($name, 0, $len); $abbrevs[$abbrev][] = $name;// 更细致的 指令名称 } } return $abbrevs;// 返回数据集合 } /** * 配置基于用户的参数和选项的输入和输出实例。 * @param Input $input 输入实例 * @param Output $output 输出实例 */ protected function configureIO(Input $input, Output $output) {// 配置基于用户的参数和选项的输入和输出实例 // Input 是个 class Output 也是个class if (true === $input->hasParameterOption(['--ansi'])) { $output->setDecorated(true);// 设置对应的 选项 } elseif (true === $input->hasParameterOption(['--no-ansi'])) { $output->setDecorated(false);// 设置对应的选项 } if (true === $input->hasParameterOption(['--no-interaction', '-n'])) { $input->setInteractive(false); }// 选项设置 if (true === $input->hasParameterOption(['--quiet', '-q'])) { $output->setVerbosity(Output::VERBOSITY_QUIET);// 选项设置 } else { if ($input->hasParameterOption('-vvv') || $input->hasParameterOption('--verbose=3') || $input->getParameterOption('--verbose') === 3) { $output->setVerbosity(Output::VERBOSITY_DEBUG); } elseif ($input->hasParameterOption('-vv') || $input->hasParameterOption('--verbose=2') || $input->getParameterOption('--verbose') === 2) { $output->setVerbosity(Output::VERBOSITY_VERY_VERBOSE); } elseif ($input->hasParameterOption('-v') || $input->hasParameterOption('--verbose=1') || $input->hasParameterOption('--verbose') || $input->getParameterOption('--verbose')) { $output->setVerbosity(Output::VERBOSITY_VERBOSE); } } }// 根据输入的选项 设置 输出的 选项 /** * 执行指令 * @param Command $command 指令实例 * @param Input $input 输入实例 * @param Output $output 输出实例 * @return int * @throws \Exception */ protected function doRunCommand(Command $command, Input $input, Output $output) { return $command->run($input, $output);// 已知输入输出 ,运行实例 }// 执行指令 /** * 获取指令的基础名称 * @param Input $input * @return string */ protected function getCommandName(Input $input) { return $input->getFirstArgument(); }// 获取指令的基础名称 /** * 获取默认输入定义 * @return InputDefinition */ protected function getDefaultInputDefinition() {// 获取 默认 输入定义 return new InputDefinition([ new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'), new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message'), new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this console version'), new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message'), new InputOption('--verbose', '-v|vv|vvv', InputOption::VALUE_NONE, 'Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug'), new InputOption('--ansi', '', InputOption::VALUE_NONE, 'Force ANSI output'), new InputOption('--no-ansi', '', InputOption::VALUE_NONE, 'Disable ANSI output'), new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Do not ask any interactive question'), ]); }// 对应的 key 及 value
0 0
- [李景山php]每天TP5-20161227|thinkphp5-Console.php-4
- [李景山php]每天TP5-20161224|thinkphp5-Console.php-1
- [李景山php]每天TP5-20161225|thinkphp5-Console.php-2
- [李景山php]每天TP5-20161228|thinkphp5-Console.php-5
- [李景山php]每天TP5-20170111|thinkphp5-Model.php-4
- [李景山php]每天TP5-20170122|thinkphp5-Process.php-4
- [李景山php]每天TP5-20170201|thinkphp5-Request.php-4
- [李景山php]每天TP5-20161216|thinkphp5-helper.php-1
- [李景山php]每天TP5-20161217|thinkphp5-helper.php-2
- [李景山php]每天TP5-20161219|thinkphp5-softDelete.php
- [李景山php]每天TP5-20161220|thinkphp5-build.php
- [李景山php]每天TP5-20161221|thinkphp5-jump.php
- [李景山php]每天TP5-20161222|thinkphp5-Cache.php
- [李景山php]每天TP5-20161223|thinkphp5-Collection.php
- [李景山php]每天TP5-20161229|thinkphp5-Controller.php
- [李景山php]每天TP5-20161230|thinkphp5-Cookie.php
- [李景山php]每天TP5-20161231|thinkphp5-Db.php
- [李景山php]每天TP5-20170101|thinkphp5-Debug.php
- 微软发布Asp.Net Core 1.1的第一个预览版本
- uart和usart的关系
- nodejs express框架 app.js文件该html模板
- C语言位域
- VS2012 中个人的使用小结
- [李景山php]每天TP5-20161227|thinkphp5-Console.php-4
- iOS引导页
- stm32配置串口步骤
- nodejs 增删该查操作数据库(routes文件夹下的users.js)
- 每天一个linux命令(3):pwd命令
- 利用valgrind 查找内存泄漏
- 无线网络优化管理面试题和笔试题
- Dubbo2.3.2中restart.sh源码
- 当ListView有Header时,onItemClick里的position不正确的解决方案