[ Index ]

PHP Cross Reference of PHK Manager

title

Body

[close]

/PHK/CLI/ -> Options.php (source)

   1  <?php
   2  //=============================================================================
   3  //
   4  // Copyright Francois Laupretre <phk@tekwire.net>
   5  //
   6  //   Licensed under the Apache License, Version 2.0 (the "License");
   7  //   you may not use this file except in compliance with the License.
   8  //   You may obtain a copy of the License at
   9  //
  10  //       http://www.apache.org/licenses/LICENSE-2.0
  11  //
  12  //   Unless required by applicable law or agreed to in writing, software
  13  //   distributed under the License is distributed on an "AS IS" BASIS,
  14  //   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15  //   See the License for the specific language governing permissions and
  16  //   limitations under the License.
  17  //
  18  //=============================================================================
  19  /**
  20  * @copyright Francois Laupretre <phk@tekwire.net>
  21  * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, V 2.0
  22  * @category PHK
  23  * @package PHK
  24  *///==========================================================================
  25  
  26  namespace PHK\CLI {
  27  
  28  if (!class_exists('PHK\CLI\Options',false))
  29  {
  30  
  31  //=============================================================================
  32  /**
  33  * This class manages options for \PHK\CLI\Cmd
  34  *
  35  * API status: Private
  36  * Included in the PHK PHP runtime: No
  37  * Implemented in the extension: No
  38  *///==========================================================================
  39  
  40  class Options extends \Phool\Options\Base
  41  {
  42  
  43  // Short/long modifier args
  44  
  45  protected $opt_modifiers=array(
  46      array('short' => 'v', 'long' => 'verbose', 'value' => false),
  47      array('short' => 'q', 'long' => 'quiet'  , 'value' => false),
  48      array('short' => 's', 'long' => 'source'  , 'value' => true),
  49      array('short' => 'd', 'long' => 'define'  , 'value' => true)
  50      );
  51  
  52  // Option values
  53  
  54  protected $options=array(
  55      'psf_path' => null,
  56      'vars' => array()
  57      );
  58  
  59  
  60  //-----------------------
  61  
  62  protected function processOption($opt,$arg)
  63  {
  64  switch($opt)
  65      {
  66      case 'v':
  67          \Phool\Display::incVerbose();
  68          break;
  69  
  70      case 'q':
  71          \Phool\Display::decVerbose();
  72          break;
  73  
  74      case 's':
  75          $this->options['psf_path']=$arg;
  76          break;
  77  
  78      case 'd':
  79          $a=explode('=',$arg,2);
  80          if ((count($a)!=2)||($a[0]===''))
  81              throw new \Exception("Invalid variable definition ($arg)");
  82          $this->options['vars'][$a[0]]=$a[1];
  83          break;
  84      }
  85  }
  86  
  87  //---
  88  } // End of class
  89  //===========================================================================
  90  } // End of class_exists
  91  //===========================================================================
  92  } // End of namespace
  93  //===========================================================================
  94  ?>


Generated: Thu Jun 4 18:33:15 2015 Cross-referenced by PHPXref 0.7.1