Source for file Help.php

Documentation is available at Help.php

  1. <?php
  2. // vim: foldmethod=marker
  3. /**
  4.  *  Plugin_Handle_Help.php
  5.  *
  6.  *  @author     Tomoyuki MARUTA <maru_cc@users.sourceforge.jp>
  7.  *  @license    http://www.opensource.org/licenses/bsd-license.php The BSD License
  8.  *  @package    Ethna
  9.  *  @version    $Id: c36b05e000b0136041f7bb96680fb79d51a28bcb $
  10.  */
  11.  
  12. // {{{ Ethna_Plugin_Handle_Help
  13. /**
  14.  *  add-action handler
  15.  *
  16.  *  @author     ICHII Takashi <ichii386@schweetheart.jp>
  17.  *  @access     public
  18.  *  @package    Ethna
  19.  */
  20. {
  21.     /**
  22.      *  show help
  23.      *
  24.      *  @access public
  25.      */
  26.     function perform()
  27.     {
  28.         $r $this->_getopt();
  29.         if (Ethna::isError($r)) {
  30.             return $r;
  31.         }
  32.         list($opt_list$arg_list$r;
  33.  
  34.         // action_name
  35.         $handle_name array_shift($arg_list);
  36.         if (!strlen($handle_name)) {
  37.             $handler_list $this->eh->getHandlerList();
  38.             printf("usage: ethna [option] [command] [args...]\n\n");
  39.             printf("available options are as follows:\n\n");
  40.             printf("  -v, --version    show version and exit\n");
  41.             printf("\navailable commands are as follows:\n\n");
  42.             foreach ($handler_list as $handler{
  43.                 printf("  %s\n"$handler->getId());
  44.             }
  45.             return true;
  46.         }
  47.  
  48.         // getHandler
  49.         $handler $this->eh->getHandler($handle_name);
  50.         if (Ethna::isError($handler|| $handler === false
  51.             // command not found
  52.             return Ethna::raiseError('command not found.''usage');
  53.         }
  54.  
  55.         echo $handler->getDescription();
  56.  
  57.         return true;
  58.  
  59.     }
  60.  
  61.     /**
  62.      *  get handler's description
  63.      *
  64.      *  @access public
  65.      */
  66.     function getDescription()
  67.     {
  68.         return <<<EOS
  69. help:
  70.     {$this->id} [command_name]
  71.  
  72. EOS;
  73.     }
  74.  
  75.     /**
  76.      *  @access public
  77.      */
  78.     function getUsage()
  79.     {
  80.         return <<<EOS
  81. ethna {$this->id} [command_name]
  82. EOS;
  83.     }
  84. }
  85. // }}}

Documentation generated on Fri, 11 Nov 2011 03:58:15 +0900 by phpDocumentor 1.4.3