ThinkPHP/Library/Vendor/Boris/CLIOptionsHandler.php

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php

/* vim: set shiftwidth=2 expandtab softtabstop=2: */

namespace Boris;

/**
 * Processes available command line flags.
 */
class CLIOptionsHandler {
  /**
   * Accept the REPL object and perform any setup necessary from the CLI flags.
   *
   * @param Boris $boris
   */
  public function handle($boris) {
    $args = getopt('hvr:', array('help', 'version', 'require:'));

    foreach ($args as $option => $value) {
      switch ($option) {
        /*
         * Sets files to load at startup, may be used multiple times,
         * i.e: boris -r test.php,foo/bar.php -r ba/foo.php --require hey.php
         */
        case 'r':
        case 'require':
          $this->_handleRequire($boris, $value);
        break;

        /*
         * Show Usage info
         */
        case 'h':
        case 'help':
          $this->_handleUsageInfo();
        break;

        /*
         * Show version
         */
        case 'v':
        case 'version':
          $this->_handleVersion();
        break;
      }
    }
  }

  // -- Private Methods

  private function _handleRequire($boris, $paths) {
    $require = array_reduce(
      (array) $paths,
      function($acc, $v) { return array_merge($acc, explode(',', $v)); },
      array()
    );

    $boris->onStart(function($worker, $scope) use($require) {
      foreach($require as $path) {
        require $path;
后面还有 25 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。