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


PHP Cli::val方法代码示例

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


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

示例1: addCell

 /**
  * Add a cell to the table.
  *
  * @param string $text The text of the cell.
  * @param array $wrap A two element array used to wrap the text in the cell.
  * @return $this Returns this object for fluent calls.
  */
 protected function addCell($text, $wrap = ['', ''])
 {
     if ($this->currentRow === null) {
         $this->row();
     }
     $i = count($this->currentRow);
     $this->columnWidths[$i] = max(strlen($text), Cli::val($i, $this->columnWidths, 0));
     // max column width
     $this->currentRow[$i] = [$text, $wrap];
     return $this;
 }
开发者ID:rodrisan,项目名称:ps-cli,代码行数:18,代码来源:Table.php

示例2: getOpt

 /**
  * Get the value of a passed option.
  *
  * @param string $option The name of the option to get.
  * @param mixed $default The default value if the option does not exist.
  * @return mixed Returns the option or {@link $default} if it does not exist.
  */
 public function getOpt($option, $default = null)
 {
     return Cli::val($option, $this->opts, $default);
 }
开发者ID:rodrisan,项目名称:ps-cli,代码行数:11,代码来源:Args.php

示例3: writeHelp

 /**
  * Writes the help for a given schema.
  *
  * @param array $schema A command line scheme returned from {@see Cli::getSchema()}.
  */
 protected function writeHelp($schema)
 {
     // Write the command description.
     $meta = Cli::val(Cli::META, $schema, []);
     $description = Cli::val('description', $meta);
     if ($description) {
         echo implode("\n", Cli::breakLines($description, 80, false)) . PHP_EOL . PHP_EOL;
     }
     unset($schema[Cli::META]);
     // Add the help.
     $schema['help'] = ['description' => 'Display this help.', 'type' => 'boolean', 'short' => '?'];
     echo Cli::bold('OPTIONS') . PHP_EOL;
     ksort($schema);
     $table = new Table();
     $table->format = $this->format;
     foreach ($schema as $key => $definition) {
         $table->row();
         // Write the keys.
         $keys = "--{$key}";
         if ($shortKey = Cli::val('short', $definition, false)) {
             $keys .= ", -{$shortKey}";
         }
         if (Cli::val('required', $definition)) {
             $table->bold($keys);
         } else {
             $table->cell($keys);
         }
         // Write the description.
         $table->cell(Cli::val('description', $definition, ''));
     }
     $table->write();
     echo PHP_EOL;
     $args = Cli::val(Cli::ARGS, $meta, []);
     if (!empty($args)) {
         echo Cli::bold('ARGUMENTS') . PHP_EOL;
         $table = new Table();
         $table->format = $this->format;
         foreach ($args as $aname => $arg) {
             $table->row();
             if (Cli::val('required', $definition)) {
                 $table->bold($aname);
             } else {
                 $table->cell($aname);
             }
             $table->cell(Cli::val('description', $arg, ''));
         }
         $table->write();
         echo PHP_EOL;
     }
 }
开发者ID:no-chris,项目名称:connector,代码行数:55,代码来源:Cli.php


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