OSDN Git Service

unify master/local handlers.
authorichii386 <ichii386@2ef88817-412d-0410-a32c-8029a115e976>
Tue, 19 Sep 2006 17:16:27 +0000 (17:16 +0000)
committerichii386 <ichii386@2ef88817-412d-0410-a32c-8029a115e976>
Tue, 19 Sep 2006 17:16:27 +0000 (17:16 +0000)
20 files changed:
CHANGES
class/Ethna_InfoManager.php
class/Ethna_PearWrapper.php
class/Ethna_Plugin.php
class/Plugin/Ethna_Plugin_Handle.php
class/Plugin/Generator/Ethna_Plugin_Generator_Plugin.php
class/Plugin/Handle/Ethna_Plugin_Handle_InfoPlugin.php [new file with mode: 0644]
class/Plugin/Handle/Ethna_Plugin_Handle_InfoPluginLocal.php [deleted file]
class/Plugin/Handle/Ethna_Plugin_Handle_InfoPluginMaster.php [deleted file]
class/Plugin/Handle/Ethna_Plugin_Handle_InstallPlugin.php [new file with mode: 0644]
class/Plugin/Handle/Ethna_Plugin_Handle_InstallPluginLocal.php [deleted file]
class/Plugin/Handle/Ethna_Plugin_Handle_InstallPluginMaster.php [deleted file]
class/Plugin/Handle/Ethna_Plugin_Handle_ListPlugin.php [new file with mode: 0644]
class/Plugin/Handle/Ethna_Plugin_Handle_ListPluginLocal.php [deleted file]
class/Plugin/Handle/Ethna_Plugin_Handle_ListPluginMaster.php [deleted file]
class/Plugin/Handle/Ethna_Plugin_Handle_UninstallPlugin.php [new file with mode: 0644]
class/Plugin/Handle/Ethna_Plugin_Handle_UninstallPluginLocal.php [deleted file]
class/Plugin/Handle/Ethna_Plugin_Handle_UninstallPluginMaster.php [deleted file]
class/View/Ethna_View_Info.php
tpl/info.tpl

diff --git a/CHANGES b/CHANGES
index 2c40506..50a55c6 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -4,6 +4,11 @@
 
 *** features
 
+- Ethna_Plugin_Handle_{Install,Uninstall,Info,List}Plugin
+-- master, local¤Î¥Ï¥ó¥É¥é¤òʬ¤±¤Æ¤¤¤¿¤Î¤òÅý¹ç
+-- ¥À¥¦¥ó¥í¡¼¥ÉºÑ¤ß¤Î tgz ¤ËÂбþ
+-- Console_GetOpt ¤Ç --channel, --basedir, --local, --master ¤Î¥ª¥×¥·¥ç¥ó¤òÄɲÃ
+-- new PEAR_Error() »þ¤Î error handler ¤ò callback($ui, 'displayFatalError') ¤ËÊѹ¹
 - Ethna_UrlHandler¥¯¥é¥¹¤òÄɲÃ(¥¹¥Æ¥­urlÂбþ)
 - Smarty¥×¥é¥°¥¤¥ó´Ø¿ôsmarty_function_urlÄɲÃ
 - Ethna_AppObject¤«¤é¤Î¥Õ¥©¡¼¥àÄêµÁÀ¸À®¥µ¥Ý¡¼¥ÈÄɲÃ
index ece2845..06e15b0 100644 (file)
@@ -688,25 +688,6 @@ class Ethna_InfoManager extends Ethna_AppManager
         }
         $r['¥Õ¥£¥ë¥¿'] = $elts;
 
-        // plugin
-        // XXX: ¼ê½ñ¤­¤ò¤Ê¤ó¤È¤«¤¹¤ë
-        $plugin_type_list = array(
-                'Cachemanager',
-                'Filter',
-                'Handle',
-                'Logwriter',
-                'Validator'
-                );
-        foreach ($plugin_type_list as $type) {
-            $elts = array();
-            $plugin = $this->ctl->getPlugin();
-            $plugin->_searchAllPluginSrc($type);
-            foreach (array_keys($plugin->src_registry[$type]) as $name) {
-                $elts[$name] = $plugin->src_registry[$type][$name][1];
-            }
-            $r["¥×¥é¥°¥¤¥ó ({$type})"] = $elts;
-        }
-
         // manager
         $elts = array();
         foreach ($this->ctl->getManagerList() as $key => $manager) {
@@ -717,6 +698,32 @@ class Ethna_InfoManager extends Ethna_AppManager
 
         return $r;
     }
+
+    /**
+     *  ¥×¥é¥°¥¤¥ó¤Î°ìÍ÷¤ò¼èÆÀ¤¹¤ë
+     *
+     *  @access public
+     *  @return array   ÀßÄê°ìÍ÷¤ò³ÊǼ¤·¤¿ÇÛÎó
+     *  @todo   respect access controll
+     */
+    function getPluginList()
+    {
+        $r = array();
+        $plugin = $this->ctl->getPlugin();
+        foreach ($plugin->searchAllPluginType() as $type) {
+            $plugin->searchAllPluginSrc($type);
+            if (isset($plugin->src_registry[$type])) {
+                $elts = array();
+                foreach ($plugin->src_registry[$type] as $name => $src) {
+                    $elts[$name] = $src[2];
+                }
+                ksort($elts);
+                $r[$type] = $elts;
+            }
+        }
+        ksort($r);
+        return $r;
+    }
 }
 // }}}
 ?>
index d889048..5a06afa 100644 (file)
@@ -12,6 +12,7 @@
 include_once('PEAR.php');
 include_once('PEAR/Config.php');
 include_once('PEAR/Command.php');
+include_once('PEAR/PackageFile.php');
 
 // {{{ Ethna_PearWrapper
 /**
@@ -64,7 +65,7 @@ class Ethna_PearWrapper
      *  @return true|Ethna_Error
      *  @access private
      */
-    function &init($target = 'master', $app_dir = null)
+    function &init($target = 'master', $app_dir = null, $channel = null)
     {
         $true = true;
 
@@ -73,12 +74,14 @@ class Ethna_PearWrapper
         $this->ui =& PEAR_Command::getFrontendObject();
 
         // PEAR's error handling rule
-        PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array(&$this->ui, 'displayError'));
+        PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array(&$this->ui, 'displayFatalError'));
         set_error_handler('ethna_error_handler_skip_pear');
 
         // set channel
         $master_setting = Ethna_Handle::getMasterSetting('repositry');
-        if (isset($master_setting["channel_{$target}"])) {
+        if ($channel !== null) {
+            $this->channel = $channel;
+        } else if (isset($master_setting["channel_{$target}"])) {
             $this->channel = $master_setting["channel_{$target}"];
         } else {
             $this->channel = 'pear.ethna.jp';
@@ -170,10 +173,12 @@ class Ethna_PearWrapper
             }
         }
 
-        // return if local .pearrc exists.
         $pearrc = "{$base}/skel/.pearrc";
         $this->config =& PEAR_Config::singleton($pearrc);
+
+        // return if local .pearrc exists.
         if (is_file($pearrc) && is_readable($pearrc)) {
+            $this->config->readConfigFile($pearrc);
             return $true;
         }
 
@@ -297,6 +302,29 @@ class Ethna_PearWrapper
     }
     // }}}
 
+    // {{{ doInstallFromTgz
+    /**
+     *  do install from local tgz file
+     *
+     *  @param  string  $pkg_file   local package filename
+     *  @param  string  $pkg_name   package name.
+     *  @return true|Ethna_Error
+     *  @access private 
+     */
+    function &doInstallFromTgz($pkg_file, $pkg_name)
+    {
+        $true = true;
+        $r =& $this->_run('install', array(), array($pkg_file));
+        if (PEAR::isError($r)) {
+            return $r;
+        }
+        if ($this->isInstalled($pkg_name) == false) {
+            return Ethna::raiseError("install failed (check permission etc): {$pkg_name}");
+        }
+        return $true;
+    }
+    // }}}
+
     // {{{ isInstalled
     /**
      *  check package installed
@@ -336,6 +364,26 @@ class Ethna_PearWrapper
     }
     // }}}
 
+    // {{{ getPackageNameFromTgz
+    /**
+     *  get package info from tar/tgz file.
+     *
+     *  @param  string  $filename   package file name.
+     *  @return string  package name
+     *  @access public
+     */
+    function &getPackageNameFromTgz($filename)
+    {
+        $packagefile =& new PEAR_PackageFile($this->config);
+        $info =& $packagefile->fromTgzFile($filename, PEAR_VALIDATE_NORMAL);
+        if (Ethna::isError($info)) {
+            return $info;
+        }
+        $info_array =& $info->toArray();
+        return $info_array['name'];
+    }
+    // }}}
+
     // {{{ getCanonicalPackageName
     /**
      *  get canonical package name (case sensitive)
index f6f9146..97ad477 100644 (file)
@@ -81,17 +81,20 @@ class Ethna_Plugin
     }
 
     /**
-     *  ¤¢¤ë¼ïÎà ($type) ¤Î¥×¥é¥°¥¤¥ó̾ ($name) ¤ÎÁ´¥ê¥¹¥È¤ò¼èÆÀ
+     *  ¤¢¤ë¼ïÎà ($type) ¤Î¥×¥é¥°¥¤¥ó ($name) ¤ÎÁ´¥ê¥¹¥È¤ò¼èÆÀ
      *
      *  @access public
      *  @param  string  $type   ¥×¥é¥°¥¤¥ó¤Î¼ïÎà
-     *  @return array   ¥×¥é¥°¥¤¥ó¤Î̾Á° ($name) ¤ÎÇÛÎó
+     *  @return array   ¥×¥é¥°¥¤¥ó¥ª¥Ö¥¸¥§¥¯¥È¤ÎÇÛÎó
      */
     function getPluginList($type)
     {
         $plugin_list = array();
 
-        $this->_searchAllPluginSrc($type);
+        $this->searchAllPluginSrc($type);
+        if (isset($this->src_registry[$type]) == false) {
+            return $plugin_list;
+        }
         foreach ($this->src_registry[$type] as $name => $value) {
             if (is_null($value)) {
                 continue;
@@ -300,6 +303,9 @@ class Ethna_Plugin
             list($class, $dir, $file) = $this->getPluginNaming($type, $name, $appid);
             if (file_exists("{$dir}/{$file}")) {
                 $this->logger->log(LOG_DEBUG, 'plugin file is found in search: [%s]', "{$dir}/{$file}");
+                if (isset($this->src_registry[$type]) == false) {
+                    $this->src_registry[$type] = array();
+                }
                 $this->src_registry[$type][$name] = array($class, $dir, $file);
                 return;
             }
@@ -311,18 +317,41 @@ class Ethna_Plugin
     }
 
     /**
-     *  »ØÄꤵ¤ì¤¿ $type ¤Î¥×¥é¥°¥¤¥ó (¤Î¥½¡¼¥¹) ¤ò¤¹¤Ù¤Æ¸¡º÷¤¹¤ë
+     *  ¥×¥é¥°¥¤¥ó¤Î¼ïÎà ($type) ¤ò¤¹¤Ù¤Æ¸¡º÷¤¹¤ë
      *
-     *  @todo   InfoManager ¤«¤é¸Æ¤Ó½Ð¤¹¤À¤±¤À¤¬¡¢public ¤Ë¤¹¤Ù¤­
-     *  @access private
-     *  @param  string  $type   ¥×¥é¥°¥¤¥ó¤Î¼ïÎà
+     *  @access public
+     *  @return array
      */
-    function _searchAllPluginSrc($type)
+    function searchAllPluginType()
     {
-        if (isset($this->src_registry[$type]) == false) {
-            $this->src_registry[$type] = array();
+        $type_list = array();
+        foreach (array_reverse($this->appid_list) as $appid) {
+            list(, $dir, ) = $this->getPluginNaming('', null, $appid);
+            if (is_dir($dir) == false) {
+                continue;
+            }
+            $dh = opendir($dir);
+            if (is_resource($dh) == false) {
+                continue;
+            }
+            while (($type_dir = readdir($dh)) !== false) {
+                if ($type_dir{0} != '.' && is_dir("{$dir}/{$type_dir}")) {
+                    $type_list[$type_dir] = 0;
+                }
+            }
+            closedir($dh);
         }
+        return array_keys($type_list);
+    }
 
+    /**
+     *  »ØÄꤵ¤ì¤¿ $type ¤Î¥×¥é¥°¥¤¥ó (¤Î¥½¡¼¥¹) ¤ò¤¹¤Ù¤Æ¸¡º÷¤¹¤ë
+     *
+     *  @access public
+     *  @param  string  $type   ¥×¥é¥°¥¤¥ó¤Î¼ïÎà
+     */
+    function searchAllPluginSrc($type)
+    {
         // ¸å¤Ç¸«ÉÕ¤«¤Ã¤¿¤â¤Î¤Ç¾å½ñ¤­¤¹¤ë¤Î¤Ç $this->appid_list ¤ÎµÕ½ç¤È¤¹¤ë
         $name_list = array();
         foreach (array_reverse($this->appid_list) as $appid) {
index b2ec3b6..d861188 100644 (file)
@@ -9,6 +9,8 @@
  *  @version    $Id$
  */
 
+require_once 'Console/Getopt.php';
+
 // {{{ Ethna_Plugin_Handle
 /**
  *  ¥³¥Þ¥ó¥É¥é¥¤¥ó¥Ï¥ó¥É¥é¥×¥é¥°¥¤¥ó¤Î´ðÄ쥯¥é¥¹
@@ -59,6 +61,16 @@ class Ethna_Plugin_Handle
     }
 
     /**
+     *  get handler's usage
+     *
+     *  @access public
+     */
+    function getUsage()
+    {
+        return "usage of " . $this->id;
+    }
+
+    /**
      *  set arguments
      *
      *  @access public
@@ -69,6 +81,30 @@ class Ethna_Plugin_Handle
     }
 
     /**
+     * easy getopt :)
+     * 
+     * @param   array   $long_options 
+     * @access  protected
+     * @return  array   list($opts, $args)
+     */
+    function _getopt($long_options = array())
+    {
+        $long_options = to_array($long_options);
+        $short_options = '';
+        foreach ($long_options as $lopt) {
+            $short_options .= $lopt{0};
+            if ($lopt{strlen($lopt) - 1} == '=') {
+                $short_options .= ':';
+            }
+            if ($lopt{strlen($lopt) - 2} == '=') {
+                $short_options .= ':';
+            }
+        }
+        $getopt =& new Console_Getopt();
+        return $getopt->getopt2($this->arg_list, $short_options, $long_options);
+    }
+
+    /**
      *  just perform
      *
      *  @access public
@@ -84,6 +120,8 @@ class Ethna_Plugin_Handle
      */
     function usage()
     {
+        echo "usage:\n";
+        echo $this->getUsage() . "\n\n";
     }
 }
 // }}}
index 4b14c38..973f492 100644 (file)
@@ -57,7 +57,6 @@ class Ethna_Plugin_Generator_Plugin extends Ethna_Plugin_Generator
 
     /**
      *  ¥×¥é¥°¥¤¥ó¤ò¾Ã¤¹
-     *  TODO: ¤â¤Ã¤È¤¤¤¤Êý¿Ë¤ò¹Í¤¨¤ë
      *
      *  @access public
      *  @param  string  $type       ¥×¥é¥°¥¤¥ó¤Î$type
diff --git a/class/Plugin/Handle/Ethna_Plugin_Handle_InfoPlugin.php b/class/Plugin/Handle/Ethna_Plugin_Handle_InfoPlugin.php
new file mode 100644 (file)
index 0000000..aededb4
--- /dev/null
@@ -0,0 +1,135 @@
+<?php
+// vim: foldmethod=marker
+/**
+ *     Ethna_Plugin_Handle_InfoPlugin.php
+ *
+ *  @author     ICHII Takashi <ichii386@schweetheart.jp>
+ *     @license        http://www.opensource.org/licenses/bsd-license.php The BSD License
+ *     @package        Ethna
+ *     @version        $Id$
+ */
+
+include_once(ETHNA_BASE . '/class/Ethna_PearWrapper.php');
+
+// {{{ Ethna_Plugin_Handle_InfoPlugin
+/**
+ *  info-plugin handler
+ *
+ *  @author     ICHII Takashi <ichii386@schweetheart.jp>
+ *     @access         public
+ *     @package        Ethna
+ */
+class Ethna_Plugin_Handle_InfoPlugin extends Ethna_Plugin_Handle
+{
+    // {{{ _parseArgList()
+    /**
+     * @access private
+     */
+    function &_parseArgList()
+    {
+        $r =& $this->_getopt(array('local', 'master', 'basedir=', 'channel='));
+        if (Ethna::isError($r)) {
+            return $r;
+        }
+        list($opt_list, $arg_list) = $r;
+
+        $ret = array();
+
+        // options
+        foreach ($opt_list as $opt) {
+            switch (true) {
+                case ($opt[0] == 'l' || $opt[0] == '--local'):
+                    $ret['target'] = 'local';
+                    break;
+
+                case ($opt[0] == 'm' || $opt[0] == '--master'):
+                    $ret['target'] = 'master';
+                    break;
+
+                case ($opt[0] == 'b' || $opt[0] == '--basedir'):
+                    $ret['basedir'] = $opt[1];
+                    break;
+
+                case ($opt[0] == 'c' || $opt[0] == '--channel'):
+                    $ret['channel'] = $opt[1];
+                    break;
+            }
+        }
+
+        // arguments
+        if (count($arg_list) == 2) {
+            $ret['type'] = $arg_list[0];
+            $ret['name'] = $arg_list[1];
+        }
+
+        return $ret;
+    }
+    // }}}
+
+    // {{{ perform()
+    /**
+     *  @access public
+     */
+    function perform()
+    {
+        $args =& $this->_parseArgList();
+        if (Ethna::isError($args)) {
+            return $args;
+        }
+        $pear =& new Ethna_PearWrapper();
+
+        if (isset($args['type']) && isset($args['name'])) {
+            $target = isset($args['target']) ? $args['target'] : 'master';
+            $channel = isset($args['channel']) ? $args['channel'] : null;
+            $basedir = isset($args['basedir']) ? realpath($args['basedir']) : getcwd();
+            if ($target == 'master') {
+                $pkg_name = sprintf('Ethna_Plugin_%s_%s', $args['type'], $args['name']);
+            } else {
+                $pkg_name = sprintf('Skel_Plugin_%s_%s', $args['type'], $args['name']);
+            }
+
+            $r =& $pear->init($target, $basedir, $channel);
+            if (Ethna::isError($r)) {
+                return $r;
+            }
+            $r =& $pear->doInfo($pkg_name);
+            if (Ethna::isError($r)) {
+                return $r;
+            }
+
+        } else {
+            return Ethna::raiseError('invalid number of arguments', 'usage');
+        }
+
+        return true;
+    }
+    // }}}
+
+    // {{{ getDescription()
+    /**
+     *  @access public
+     */
+    function getDescription()
+    {
+        return <<<EOS
+show plugin information:
+    {$this->id} [-c|--channel=channel] [-b|--basedir=dir] [-l|--local] [-m|--master] [type name]
+
+EOS;
+    }
+    // }}}
+
+    // {{{ getUsage()
+    /**
+     *  @access public
+     */
+    function getUsage()
+    {
+        return <<<EOS
+ethna {$this->id} [-c|--channel=channel] [-b|--basedir=dir] [-l|--local] [-m|--master] [type name]
+EOS;
+    }
+    // }}}
+}
+// }}}
+?>
diff --git a/class/Plugin/Handle/Ethna_Plugin_Handle_InfoPluginLocal.php b/class/Plugin/Handle/Ethna_Plugin_Handle_InfoPluginLocal.php
deleted file mode 100644 (file)
index 7f3c4d7..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-<?php
-// vim: foldmethod=marker
-/**
- *     Ethna_Plugin_Handle_InfoPluginLocal.php
- *
- *  @author     ICHII Takashi <ichii386@schweetheart.jp>
- *     @license        http://www.opensource.org/licenses/bsd-license.php The BSD License
- *     @package        Ethna
- *     @version        $Id$
- */
-
-include_once(ETHNA_BASE . '/class/Ethna_PearWrapper.php');
-
-// {{{ Ethna_Plugin_Handle_InfoPluginLocal
-/**
- *  info-plugin-local handler
- *
- *  @author     ICHII Takashi <ichii386@schweetheart.jp>
- *     @access         public
- *     @package        Ethna
- */
-class Ethna_Plugin_Handle_InfoPluginLocal extends Ethna_Plugin_Handle
-{
-    /**
-     *  get handler's description
-     *
-     *  @access public
-     */
-    function getDescription()
-    {
-        return "show local plugin info:\n    {$this->id} [plugin type] [plugin name] ([project-base-dir])\n";
-    }
-
-    /**
-     *  info-plugin-local
-     *
-     *  @access public
-     */
-    function perform()
-    {
-        $r = $this->_validateArgList();
-        if (Ethna::isError($r)) {
-            return $r;
-        }
-        list($plugin_type, $plugin_name, $app_dir) = $r;
-        $package = "Skel_Plugin_{$plugin_type}_{$plugin_name}";
-
-        // info
-        $pear =& new Ethna_PearWrapper();
-        $r =& $pear->init('local', $app_dir);
-        if (PEAR::isError($r)) {
-            return $r;
-        }
-        $r =& $pear->doInfo($package);
-        if (PEAR::isError($r)) {
-            return $r;
-        }
-
-        return true;
-    }
-
-    /**
-     *  show usage
-     *
-     *  @access public
-     */
-    function usage()
-    {
-        printf("usage:\nethna %s [plugin type] [plugin name] ([project-base-dir])\n\n", $this->id);
-    }
-
-    /**
-     *  check arguments
-     *
-     *  @access private
-     */
-    function _validateArgList()
-    {
-        $arg_list = array();
-        if (count($this->arg_list) < 2) {
-            return Ethna::raiseError('too few arguments', 'usage');
-        } else if (count($this->arg_list) > 3) {
-            return Ethna::raiseError('too many arguments', 'usage');
-        } else if (count($this->arg_list) == 2) {
-            $arg_list[] = $this->arg_list[0];
-            $arg_list[] = $this->arg_list[1];
-            $arg_list[] = getcwd();
-        } else {
-            $arg_list = $this->arg_list;
-        }
-
-        return $arg_list;
-    }
-}
-// }}}
-
-?>
diff --git a/class/Plugin/Handle/Ethna_Plugin_Handle_InfoPluginMaster.php b/class/Plugin/Handle/Ethna_Plugin_Handle_InfoPluginMaster.php
deleted file mode 100644 (file)
index 517e6a0..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-<?php
-// vim: foldmethod=marker
-/**
- *     Ethna_Plugin_Handle_InfoPluginMaster.php
- *
- *  @author     ICHII Takashi <ichii386@schweetheart.jp>
- *     @license        http://www.opensource.org/licenses/bsd-license.php The BSD License
- *     @package        Ethna
- *     @version        $Id$
- */
-
-include_once(ETHNA_BASE . '/class/Ethna_PearWrapper.php');
-
-// {{{ Ethna_Plugin_Handle_InfoPluginMaster
-/**
- *  info-plugin-master handler
- *
- *  @author     ICHII Takashi <ichii386@schweetheart.jp>
- *     @access         public
- *     @package        Ethna
- */
-class Ethna_Plugin_Handle_InfoPluginMaster extends Ethna_Plugin_Handle
-{
-    /**
-     *  get handler's description
-     *
-     *  @access public
-     */
-    function getDescription()
-    {
-        return "show master plugin info:\n    {$this->id} [plugin type] [plugin name]\n";
-    }
-
-    /**
-     *  info-plugin-master
-     *
-     *  @access public
-     */
-    function perform()
-    {
-        $r = $this->_validateArgList();
-        if (Ethna::isError($r)) {
-            return $r;
-        }
-        list($plugin_type, $plugin_name) = $r;
-        $package = "Ethna_Plugin_{$plugin_type}_{$plugin_name}";
-
-        // info
-        $pear =& new Ethna_PearWrapper();
-        $r =& $pear->init('master');
-        if (PEAR::isError($r)) {
-            return $r;
-        }
-        $r =& $pear->doInfo($package);
-        if (PEAR::isError($r)) {
-            return $r;
-        }
-
-        return true;
-    }
-
-    /**
-     *  show usage
-     *
-     *  @access public
-     */
-    function usage()
-    {
-        printf("usage:\nethna %s [plugin type] [plugin name]\n\n", $this->id);
-    }
-
-    /**
-     *  check arguments
-     *
-     *  @access private
-     */
-    function _validateArgList()
-    {
-        $arg_list = array();
-        if (count($this->arg_list) < 2) {
-            return Ethna::raiseError('too few arguments', 'usage');
-        } else if (count($this->arg_list) > 2) {
-            return Ethna::raiseError('too many arguments', 'usage');
-        } else {
-            $arg_list = $this->arg_list;
-        }
-
-        return $arg_list;
-    }
-}
-// }}}
-
-?>
diff --git a/class/Plugin/Handle/Ethna_Plugin_Handle_InstallPlugin.php b/class/Plugin/Handle/Ethna_Plugin_Handle_InstallPlugin.php
new file mode 100644 (file)
index 0000000..9089d65
--- /dev/null
@@ -0,0 +1,174 @@
+<?php
+// vim: foldmethod=marker
+/**
+ *     Ethna_Plugin_Handle_InstallPlugin.php
+ *
+ *  @author     ICHII Takashi <ichii386@schweetheart.jp>
+ *     @license        http://www.opensource.org/licenses/bsd-license.php The BSD License
+ *     @package        Ethna
+ *     @version        $Id$
+ */
+
+include_once(ETHNA_BASE . '/class/Ethna_PearWrapper.php');
+
+// {{{ Ethna_Plugin_Handle_InstallPlugin
+/**
+ *  install-plugin handler
+ *
+ *  @author     ICHII Takashi <ichii386@schweetheart.jp>
+ *     @access         public
+ *     @package        Ethna
+ */
+class Ethna_Plugin_Handle_InstallPlugin extends Ethna_Plugin_Handle
+{
+    // {{{ _parseArgList()
+    /**
+     * @access private
+     */
+    function &_parseArgList()
+    {
+        $r =& $this->_getopt(array('local', 'master', 'basedir=', 'channel='));
+        if (Ethna::isError($r)) {
+            return $r;
+        }
+        list($opt_list, $arg_list) = $r;
+
+        $ret = array();
+
+        // options
+        foreach ($opt_list as $opt) {
+            switch (true) {
+                case ($opt[0] == 'l' || $opt[0] == '--local'):
+                    $ret['target'] = 'local';
+                    break;
+
+                case ($opt[0] == 'm' || $opt[0] == '--master'):
+                    $ret['target'] = 'master';
+                    break;
+
+                case ($opt[0] == 'b' || $opt[0] == '--basedir'):
+                    $ret['basedir'] = $opt[1];
+                    break;
+
+                case ($opt[0] == 'c' || $opt[0] == '--channel'):
+                    $ret['channel'] = $opt[1];
+                    break;
+            }
+        }
+
+        // arguments
+        if (count($arg_list) == 2) {
+            $ret['type'] = $arg_list[0];
+            $ret['name'] = $arg_list[1];
+        } else if (count($arg_list) == 1) {
+            $ret['pkg_file'] = $arg_list[0];
+        }
+
+        return $ret;
+    }
+    // }}}
+
+    // {{{ perform()
+    /**
+     *  @access public
+     */
+    function perform()
+    {
+        $args =& $this->_parseArgList();
+        if (Ethna::isError($args)) {
+            return $args;
+        }
+        $pear =& new Ethna_PearWrapper();
+
+        if (isset($args['pkg_file'])) {
+            // install from local tgz.
+            $pear->init();
+            $pkg_file = $args['pkg_file'];
+            $pkg_name =& $pear->getPackageNameFromTgz($pkg_file);
+            if (Ethna::isError($pkg_name)) {
+                return $pkg_name;
+            }
+            list($appid,, $ctype, $cname) = explode('_', $pkg_name, 4);
+            $target = $appid == 'Ethna' ? 'master' : 'local';
+            $channel = isset($args['channel']) ? $args['channel'] : null;
+            $basedir = isset($args['basedir']) ? realpath($args['basedir']) : getcwd();
+
+            $r =& $pear->init($target, $basedir, $channel);
+            if (Ethna::isError($r)) {
+                return $r;
+            }
+            $r =& $pear->doInstallFromTgz($pkg_file, $pkg_name);
+            if (Ethna::isError($r)) {
+                return $r;
+            }
+
+        } else if (isset($args['type']) && isset($args['name'])) {
+            // install from repository.
+            $target = isset($args['target']) ? $args['target'] : 'master';
+            $channel = isset($args['channel']) ? $args['channel'] : null;
+            $basedir = isset($args['basedir']) ? realpath($args['basedir']) : getcwd();
+            if ($target == 'master') {
+                $pkg_name = sprintf('Ethna_Plugin_%s_%s', $args['type'], $args['name']);
+            } else {
+                $pkg_name = sprintf('Skel_Plugin_%s_%s', $args['type'], $args['name']);
+            }
+
+            $r =& $pear->init($target, $basedir, $channel);
+            if (Ethna::isError($r)) {
+                return $r;
+            }
+            $r =& $pear->doInstall($pkg_name);
+            if (Ethna::isError($r)) {
+                return $r;
+            }
+
+            $pkg_name = $pear->getCanonicalPackageName($pkg_name);
+            if (Ethna::isError($pkg_name)) {
+                return $pkg_name;
+            }
+
+        } else {
+            return Ethna::raiseError('invalid number of arguments', 'usage');
+        }
+
+        if ($target == 'local') {
+            list(,, $ctype, $cname) = explode('_', $pkg_name, 4);
+            $generator =& new Ethna_Generator();
+            $r = $generator->generate('Plugin', $ctype, $cname, $basedir);
+            if (Ethna::isError($r)) {
+                return $r;
+            }
+        }
+
+        return true;
+    }
+    // }}}
+
+    // {{{ getDescription()
+    /**
+     *  @access public
+     */
+    function getDescription()
+    {
+        return <<<EOS
+install plugin to project directory:
+    {$this->id} [-c|--channel=channel] [-b|--basedir=dir] [-l|--local] [-m|--master] [type name|packagefile]
+
+EOS;
+    }
+    // }}}
+
+    // {{{
+    /**
+     *  @access public
+     */
+    function getUsage()
+    {
+        return <<<EOS
+ethna {$this->id} [-c|--channel=channel] [-b|--basedir=dir] [-l|--local] [-m|--master] [type name|packagefile]
+EOS;
+    }
+    // }}}
+}
+// }}}
+?>
diff --git a/class/Plugin/Handle/Ethna_Plugin_Handle_InstallPluginLocal.php b/class/Plugin/Handle/Ethna_Plugin_Handle_InstallPluginLocal.php
deleted file mode 100644 (file)
index 1e99726..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-<?php
-// vim: foldmethod=marker
-/**
- *     Ethna_Plugin_Handle_InstallPluginLocal.php
- *
- *  @author     ICHII Takashi <ichii386@schweetheart.jp>
- *     @license        http://www.opensource.org/licenses/bsd-license.php The BSD License
- *     @package        Ethna
- *     @version        $Id$
- */
-
-include_once(ETHNA_BASE . '/class/Ethna_PearWrapper.php');
-
-// {{{ Ethna_Plugin_Handle_InstallPluginLocal
-/**
- *  install-local-plugin handler
- *
- *  @author     ICHII Takashi <ichii386@schweetheart.jp>
- *     @access         public
- *     @package        Ethna
- */
-class Ethna_Plugin_Handle_InstallPluginLocal extends Ethna_Plugin_Handle
-{
-    /**
-     *  get handler's description
-     *
-     *  @access public
-     */
-    function getDescription()
-    {
-        return "install local plugin to project directory:\n    {$this->id} [plugin type] [plugin name] ([project-base-dir])\n";
-    }
-
-    /**
-     *  install-plugin-local
-     *
-     *  @access public
-     */
-    function perform()
-    {
-        $r = $this->_validateArgList();
-        if (Ethna::isError($r)) {
-            return $r;
-        }
-        list($plugin_type, $plugin_name, $app_dir) = $r;
-        $package = "Skel_Plugin_{$plugin_type}_{$plugin_name}";
-
-        $pear =& new Ethna_PearWrapper();
-        $r =& $pear->init('local', $app_dir);
-        if (Ethna::isError($r)) {
-            return $r;
-        }
-
-        // install
-        $r =& $pear->doInstall($package);
-        if (Ethna::isError($r)) {
-            return $r;
-        }
-
-        // get ctype, cname
-        $cpackage = $pear->getCanonicalPackageName($package);
-        if (Ethna::isError($cpackage)) {
-            return $cpackage;
-        }
-        list(,, $ctype, $cname) = explode('_', $cpackage, 4);
-
-        // generate plugin by skelton
-        $ok = $pear->confirmDialog('generate a plugin from skelton? (could overwrite files already exist)');
-        if ($ok) {
-            $generator =& new Ethna_Generator();
-            $r = $generator->generate('Plugin', $ctype, $cname, $app_dir);
-            if (Ethna::isError($r)) {
-                printf("error occurred while generating plugin. please see also following error message(s)\n\n");
-                return $r;
-            }
-        }
-
-        return true;
-    }
-
-    /**
-     *  show usage
-     *
-     *  @access public
-     */
-    function usage()
-    {
-        printf("usage:\nethna %s [plugin type] [plugin name] ([project-base-dir])\n\n", $this->id);
-    }
-
-    /**
-     *  check arguments
-     *
-     *  @access private
-     */
-    function _validateArgList()
-    {
-        $arg_list = array();
-        if (count($this->arg_list) < 2) {
-            return Ethna::raiseError('too few arguments', 'usage');
-        } else if (count($this->arg_list) > 3) {
-            return Ethna::raiseError('too many arguments', 'usage');
-        } else if (count($this->arg_list) == 2) {
-            $arg_list[] = $this->arg_list[0];
-            $arg_list[] = $this->arg_list[1];
-            $arg_list[] = getcwd();
-        } else {
-            $arg_list = $this->arg_list;
-        }
-
-        return $arg_list;
-    }
-}
-// }}}
-?>
diff --git a/class/Plugin/Handle/Ethna_Plugin_Handle_InstallPluginMaster.php b/class/Plugin/Handle/Ethna_Plugin_Handle_InstallPluginMaster.php
deleted file mode 100644 (file)
index dad6d6c..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-<?php
-// vim: foldmethod=marker
-/**
- *     Ethna_Plugin_Handle_InstallPluginMaster.php
- *
- *  @author     ICHII Takashi <ichii386@schweetheart.jp>
- *     @license        http://www.opensource.org/licenses/bsd-license.php The BSD License
- *     @package        Ethna
- *     @version        $Id$
- */
-
-include_once(ETHNA_BASE . '/class/Ethna_PearWrapper.php');
-
-// {{{ Ethna_Plugin_Handle_InstallPluginMaster
-/**
- *  install-plugin-master handler
- *
- *  @author     ICHII Takashi <ichii386@schweetheart.jp>
- *     @access         public
- *     @package        Ethna
- */
-class Ethna_Plugin_Handle_InstallPluginMaster extends Ethna_Plugin_Handle
-{
-    /**
-     *  get handler's description
-     *
-     *  @access public
-     */
-    function getDescription()
-    {
-        return "install master plugin to Ethna directory:\n    {$this->id} [plugin type] [plugin name]\n";
-    }
-
-    /**
-     *  install-plugin-master
-     *
-     *  @access public
-     */
-    function perform()
-    {
-        $r = $this->_validateArgList();
-        if (Ethna::isError($r)) {
-            return $r;
-        }
-        list($plugin_type, $plugin_name) = $r;
-        $package = "Ethna_Plugin_{$plugin_type}_{$plugin_name}";
-
-        // install
-        $pear =& new Ethna_PearWrapper();
-        $r =& $pear->init('master');
-        if (Ethna::isError($r)) {
-            return $r;
-        }
-        $r =& $pear->doInstall($package);
-        if (Ethna::isError($r)) {
-            return $r;
-        }
-
-        return true;
-    }
-
-    /**
-     *  show usage
-     *
-     *  @access public
-     */
-    function usage()
-    {
-        printf("usage:\nethna %s [plugin type] [plugin name]\n\n", $this->id);
-    }
-
-    /**
-     *  check arguments
-     *
-     *  @access private
-     */
-    function _validateArgList()
-    {
-        $arg_list = array();
-        if (count($this->arg_list) < 2) {
-            return Ethna::raiseError('too few arguments', 'usage');
-        } else if (count($this->arg_list) > 2) {
-            return Ethna::raiseError('too many arguments', 'usage');
-        } else {
-            $arg_list = $this->arg_list;
-        }
-
-        return $arg_list;
-    }
-}
-// }}}
-?>
diff --git a/class/Plugin/Handle/Ethna_Plugin_Handle_ListPlugin.php b/class/Plugin/Handle/Ethna_Plugin_Handle_ListPlugin.php
new file mode 100644 (file)
index 0000000..3a4282a
--- /dev/null
@@ -0,0 +1,121 @@
+<?php
+// vim: foldmethod=marker
+/**
+ *     Ethna_Plugin_Handle_ListPlugin.php
+ *
+ *  @author     ICHII Takashi <ichii386@schweetheart.jp>
+ *     @license        http://www.opensource.org/licenses/bsd-license.php The BSD License
+ *     @package        Ethna
+ *     @version        $Id$
+ */
+
+include_once(ETHNA_BASE . '/class/Ethna_PearWrapper.php');
+
+// {{{ Ethna_Plugin_Handle_ListPlugin
+/**
+ *  list-plugin handler
+ *
+ *  @author     ICHII Takashi <ichii386@schweetheart.jp>
+ *     @access         public
+ *     @package        Ethna
+ */
+class Ethna_Plugin_Handle_ListPlugin extends Ethna_Plugin_Handle
+{
+    // {{{ _parseArgList()
+    /**
+     * @access private
+     */
+    function &_parseArgList()
+    {
+        $r =& $this->_getopt(array('local', 'master', 'basedir=', 'channel='));
+        if (Ethna::isError($r)) {
+            return $r;
+        }
+        list($opt_list, $arg_list) = $r;
+
+        $ret = array();
+
+        // options
+        foreach ($opt_list as $opt) {
+            switch (true) {
+                case ($opt[0] == 'l' || $opt[0] == '--local'):
+                    $ret['target'] = 'local';
+                    break;
+
+                case ($opt[0] == 'm' || $opt[0] == '--master'):
+                    $ret['target'] = 'master';
+                    break;
+
+                case ($opt[0] == 'b' || $opt[0] == '--basedir'):
+                    $ret['basedir'] = $opt[1];
+                    break;
+
+                case ($opt[0] == 'c' || $opt[0] == '--channel'):
+                    $ret['channel'] = $opt[1];
+                    break;
+            }
+        }
+
+        return $ret;
+    }
+    // }}}
+
+    // {{{ perform()
+    /**
+     *  @access public
+     */
+    function perform()
+    {
+        $args =& $this->_parseArgList();
+        if (Ethna::isError($args)) {
+            return $args;
+        }
+        $pear =& new Ethna_PearWrapper();
+
+        // list installed packages.
+        $target = isset($args['target']) ? $args['target'] : 'master';
+        $channel = isset($args['channel']) ? $args['channel'] : null;
+        $basedir = isset($args['basedir']) ? realpath($args['basedir']) : getcwd();
+
+        $r =& $pear->init($target, $basedir, $channel);
+        if (Ethna::isError($r)) {
+            return $r;
+        }
+        $r =& $pear->doList();
+        if (Ethna::isError($r)) {
+            return $r;
+        }
+
+        return true;
+    }
+    // }}}
+
+    // {{{ getDescription()
+    /**
+     *  @access public
+     */
+    function getDescription()
+    {
+        return <<<EOS
+list installed plugins:
+    {$this->id} [-c|--channel=channel] [-b|--basedir=dir] [-l|--local] [-m|--master]
+
+EOS;
+    }
+    // }}}
+
+    // {{{ getUsage()
+    /**
+     *  @access public
+     */
+    function getUsage()
+    {
+        return <<<EOS
+ethna {$this->id} [-c|--channel=channel] [-b|--basedir=dir] [-l|--local] [-m|--master]
+EOS;
+    }
+    // }}}
+}
+// }}}
+
+?>
diff --git a/class/Plugin/Handle/Ethna_Plugin_Handle_ListPluginLocal.php b/class/Plugin/Handle/Ethna_Plugin_Handle_ListPluginLocal.php
deleted file mode 100644 (file)
index 4d263e8..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-<?php
-// vim: foldmethod=marker
-/**
- *     Ethna_Plugin_Handle_ListPluginLocal.php
- *
- *  @author     ICHII Takashi <ichii386@schweetheart.jp>
- *     @license        http://www.opensource.org/licenses/bsd-license.php The BSD License
- *     @package        Ethna
- *     @version        $Id$
- */
-
-include_once(ETHNA_BASE . '/class/Ethna_PearWrapper.php');
-
-// {{{ Ethna_Plugin_Handle_ListPluginLocal
-/**
- *  list-plugin-local handler
- *
- *  @author     ICHII Takashi <ichii386@schweetheart.jp>
- *     @access         public
- *     @package        Ethna
- */
-class Ethna_Plugin_Handle_ListPluginLocal extends Ethna_Plugin_Handle
-{
-    /**
-     *  get handler's description
-     *
-     *  @access public
-     */
-    function getDescription()
-    {
-        return "list local plugins installed on the project directory:\n    {$this->id} ([project-base-dir])\n";
-    }
-
-    /**
-     *  list-plugin-local
-     *  TODO: pear list ¤·¤Æ¤¤¤ë¤À¤±¤Ê¤Î¤ò plugin specific ¤Ë¤¹¤ë
-     *
-     *  @access public
-     */
-    function perform()
-    {
-        $r = $this->_validateArgList();
-        if (Ethna::isError($r)) {
-            return $r;
-        }
-        list($app_dir) = $r;
-
-        // list
-        $pear =& new Ethna_PearWrapper();
-        $r =& $pear->init('local', $app_dir);
-        if (Ethna::isError($r)) {
-            return $r;
-        }
-        $r =& $pear->doList();
-        if (Ethna::isError($r)) {
-            return $r;
-        }
-
-        return true;
-    }
-
-    /**
-     *  show usage
-     *
-     *  @access public
-     */
-    function usage()
-    {
-        printf("usage:\nethna %s ([project-base-dir])\n\n", $this->id);
-    }
-
-    /**
-     *  check arguments
-     *
-     *  @access private
-     */
-    function _validateArgList()
-    {
-        $arg_list = array();
-        if (count($this->arg_list) < 0) {
-            return Ethna::raiseError('too few arguments', 'usage');
-        } else if (count($this->arg_list) > 1) {
-            return Ethna::raiseError('too many arguments', 'usage');
-        } else if (count($this->arg_list) == 0) {
-            $arg_list[] = getcwd();
-        } else {
-            $arg_list = $this->arg_list;
-        }
-
-        return $arg_list;
-    }
-}
-// }}}
-?>
diff --git a/class/Plugin/Handle/Ethna_Plugin_Handle_ListPluginMaster.php b/class/Plugin/Handle/Ethna_Plugin_Handle_ListPluginMaster.php
deleted file mode 100644 (file)
index ae7a985..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-<?php
-// vim: foldmethod=marker
-/**
- *     Ethna_Plugin_Handle_ListPluginMaster.php
- *
- *  @author     ICHII Takashi <ichii386@schweetheart.jp>
- *     @license        http://www.opensource.org/licenses/bsd-license.php The BSD License
- *     @package        Ethna
- *     @version        $Id$
- */
-
-include_once(ETHNA_BASE . '/class/Ethna_PearWrapper.php');
-
-// {{{ Ethna_Plugin_Handle_ListPluginMaster
-/**
- *  list-plugin-master handler
- *
- *  @author     ICHII Takashi <ichii386@schweetheart.jp>
- *     @access         public
- *     @package        Ethna
- */
-class Ethna_Plugin_Handle_ListPluginMaster extends Ethna_Plugin_Handle
-{
-    /**
-     *  get handler's description
-     *
-     *  @access public
-     */
-    function getDescription()
-    {
-        return "list master plugins installed on Ethna directory:\n    {$this->id}\n";
-    }
-
-    /**
-     *  list-plugin-master
-     *  TODO: pear list ¤·¤Æ¤¤¤ë¤À¤±¤Ê¤Î¤ò plugin specific ¤Ë¤¹¤ë
-     *
-     *  @access public
-     */
-    function perform()
-    {
-        $r = $this->_validateArgList();
-        if (Ethna::isError($r)) {
-            return $r;
-        }
-
-        // list
-        $pear =& new Ethna_PearWrapper();
-        $r =& $pear->init('master');
-        if (Ethna::isError($r)) {
-            return $r;
-        }
-        $r =& $pear->doList();
-        if (Ethna::isError($r)) {
-            return $r;
-        }
-
-        return true;
-    }
-
-    /**
-     *  show usage
-     *
-     *  @access public
-     */
-    function usage()
-    {
-        printf("usage:\nethna %s\n\n", $this->id);
-    }
-
-    /**
-     *  check arguments
-     *
-     *  @access private
-     */
-    function _validateArgList()
-    {
-        $arg_list = array();
-        if (count($this->arg_list) < 0) {
-            return Ethna::raiseError('too few arguments', 'usage');
-        } else if (count($this->arg_list) > 0) {
-            return Ethna::raiseError('too many arguments', 'usage');
-        } else {
-            $arg_list = $this->arg_list;
-        }
-
-        return $arg_list;
-    }
-}
-// }}}
-?>
diff --git a/class/Plugin/Handle/Ethna_Plugin_Handle_UninstallPlugin.php b/class/Plugin/Handle/Ethna_Plugin_Handle_UninstallPlugin.php
new file mode 100644 (file)
index 0000000..9c5bff7
--- /dev/null
@@ -0,0 +1,152 @@
+<?php
+// vim: foldmethod=marker
+/**
+ *     Ethna_Plugin_Handle_UninstallPlugin.php
+ *
+ *  @author     ICHII Takashi <ichii386@schweetheart.jp>
+ *     @license        http://www.opensource.org/licenses/bsd-license.php The BSD License
+ *     @package        Ethna
+ *     @version        $Id$
+ */
+
+include_once(ETHNA_BASE . '/class/Ethna_PearWrapper.php');
+
+// {{{ Ethna_Plugin_Handle_UninstallPlugin
+/**
+ *  install-plugin handler
+ *
+ *  @author     ICHII Takashi <ichii386@schweetheart.jp>
+ *     @access         public
+ *     @package        Ethna
+ */
+class Ethna_Plugin_Handle_UninstallPlugin extends Ethna_Plugin_Handle
+{
+    // {{{ _parseArgList()
+    /**
+     * @access private
+     */
+    function &_parseArgList()
+    {
+        $r =& $this->_getopt(array('local', 'master', 'basedir=', 'channel='));
+        if (Ethna::isError($r)) {
+            return $r;
+        }
+        list($opt_list, $arg_list) = $r;
+
+        $ret = array();
+
+        // options
+        foreach ($opt_list as $opt) {
+            switch (true) {
+                case ($opt[0] == 'l' || $opt[0] == '--local'):
+                    $ret['target'] = 'local';
+                    break;
+
+                case ($opt[0] == 'm' || $opt[0] == '--master'):
+                    $ret['target'] = 'master';
+                    break;
+
+                case ($opt[0] == 'b' || $opt[0] == '--basedir'):
+                    $ret['basedir'] = $opt[1];
+                    break;
+
+                case ($opt[0] == 'c' || $opt[0] == '--channel'):
+                    $ret['channel'] = $opt[1];
+                    break;
+            }
+        }
+
+        // arguments
+        if (count($arg_list) == 2) {
+            $ret['type'] = $arg_list[0];
+            $ret['name'] = $arg_list[1];
+        }
+
+        return $ret;
+    }
+    // }}}
+
+    // {{{ perform()
+    /**
+     *  @access public
+     */
+    function perform()
+    {
+        $args =& $this->_parseArgList();
+        if (Ethna::isError($args)) {
+            return $args;
+        }
+        $pear =& new Ethna_PearWrapper();
+
+        if (isset($args['type']) && isset($args['name'])) {
+            // install from repository.
+            $target = isset($args['target']) ? $args['target'] : 'master';
+            $channel = isset($args['channel']) ? $args['channel'] : null;
+            $basedir = isset($args['basedir']) ? realpath($args['basedir']) : getcwd();
+            if ($target == 'master') {
+                $pkg_name = sprintf('Ethna_Plugin_%s_%s', $args['type'], $args['name']);
+            } else {
+                $pkg_name = sprintf('Skel_Plugin_%s_%s', $args['type'], $args['name']);
+            }
+
+            $r =& $pear->init($target, $basedir, $channel);
+            if (Ethna::isError($r)) {
+                return $r;
+            }
+            $pkg_name = $pear->getCanonicalPackageName($pkg_name);
+            if (Ethna::isError($pkg_name)) {
+                return $pkg_name;
+            }
+            $r =& $pear->doUninstall($pkg_name);
+            if (Ethna::isError($r)) {
+                return $r;
+            }
+
+        } else {
+            return Ethna::raiseError('invalid number of arguments', 'usage');
+        }
+
+        if ($target == 'local') {
+            list(,, $ctype, $cname) = explode('_', $pkg_name, 4);
+            $ok = $pear->confirmDialog('delete plugin generated from skelton? (could delete locally modified files)');
+            if ($ok) {
+                $generator =& new Ethna_Generator();
+                $r = $generator->remove('Plugin', $ctype, $cname, $basedir);
+                if (Ethna::isError($r)) {
+                    return $r;
+                }
+            }
+        }
+
+        return true;
+    }
+    // }}}
+
+    // {{{ getDescription()
+    /**
+     *  @access public
+     */
+    function getDescription()
+    {
+        return <<<EOS
+install plugin to project directory:
+    {$this->id} [-c|--channel=channel] [-b|--basedir=dir] [-l|--local] [-m|--master] [type name]
+
+EOS;
+    }
+    // }}}
+
+    // {{{
+    /**
+     *  @access public
+     */
+    function getUsage()
+    {
+        return <<<EOS
+ethna {$this->id} [-c|--channel=channel] [-b|--basedir=dir] [-l|--local] [-m|--master] [type name]
+EOS;
+    }
+    // }}}
+}
+// }}}
+?>
diff --git a/class/Plugin/Handle/Ethna_Plugin_Handle_UninstallPluginLocal.php b/class/Plugin/Handle/Ethna_Plugin_Handle_UninstallPluginLocal.php
deleted file mode 100644 (file)
index aa2856f..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-<?php
-// vim: foldmethod=marker
-/**
- *     Ethna_Plugin_Handle_UninstallPluginLocal.php
- *
- *  @author     ICHII Takashi <ichii386@schweetheart.jp>
- *     @license        http://www.opensource.org/licenses/bsd-license.php The BSD License
- *     @package        Ethna
- *     @version        $Id$
- */
-
-include_once(ETHNA_BASE . '/class/Ethna_PearWrapper.php');
-
-// {{{ Ethna_Plugin_Handle_UninstallPluginLocal
-/**
- *  uninstall-plugin-local handler
- *
- *  @author     ICHII Takashi <ichii386@schweetheart.jp>
- *     @access         public
- *     @package        Ethna
- */
-class Ethna_Plugin_Handle_UninstallPluginLocal extends Ethna_Plugin_Handle
-{
-    /**
-     *  get handler's description
-     *
-     *  @access public
-     */
-    function getDescription()
-    {
-        return "uninstall local plugin from project directory:\n    {$this->id} [plugin type] [plugin name] ([project-base-dir])\n";
-    }
-
-    /**
-     *  uninstall-plugin-local
-     *
-     *  @access public
-     */
-    function perform()
-    {
-        $r = $this->_validateArgList();
-        if (Ethna::isError($r)) {
-            return $r;
-        }
-        list($plugin_type, $plugin_name, $app_dir) = $r;
-        $package = "Skel_Plugin_{$plugin_type}_{$plugin_name}";
-
-        // initialize
-        $pear =& new Ethna_PearWrapper();
-        $r =& $pear->init('local', $app_dir);
-        if (Ethna::isError($r)) {
-            return $r;
-        }
-
-        // get ctype, cname
-        $cpackage = $pear->getCanonicalPackageName($package);
-        if (Ethna::isError($cpackage)) {
-            return $cpackage;
-        }
-        list(,, $ctype, $cname) = explode('_', $cpackage, 4);
-
-        // uninstall
-        $r = $pear->doUninstall($package);
-        if (Ethna::isError($r)) {
-            return $r;
-        }
-
-        // delete generated plugin
-        $ok = $pear->confirmDialog('delete plugin generated from skelton? (could delete locally modified files)');
-        if ($ok) {
-            $generator =& new Ethna_Generator();
-            $r = $generator->remove('Plugin', $ctype, $cname, $app_dir);
-            if (Ethna::isError($r)) {
-                printf("error occurred while deleting plugin. please see also following error message(s)\n\n");
-                return $r;
-            }
-        }
-
-        return true;
-    }
-
-    /**
-     *  show usage
-     *
-     *  @access public
-     */
-    function usage()
-    {
-        printf("usage:\nethna %s [plugin type] [plugin name] ([project-base-dir])\n\n", $this->id);
-    }
-
-    /**
-     *  check arguments
-     *
-     *  @access private
-     */
-    function _validateArgList()
-    {
-        $arg_list = array();
-        if (count($this->arg_list) < 2) {
-            return Ethna::raiseError('too few arguments', 'usage');
-        } else if (count($this->arg_list) > 3) {
-            return Ethna::raiseError('too many arguments', 'usage');
-        } else if (count($this->arg_list) == 2) {
-            $arg_list[] = $this->arg_list[0];
-            $arg_list[] = $this->arg_list[1];
-            $arg_list[] = getcwd();
-        } else {
-            $arg_list = $this->arg_list;
-        }
-
-        return $arg_list;
-    }
-}
-// }}}
-?>
diff --git a/class/Plugin/Handle/Ethna_Plugin_Handle_UninstallPluginMaster.php b/class/Plugin/Handle/Ethna_Plugin_Handle_UninstallPluginMaster.php
deleted file mode 100644 (file)
index 3f72ba3..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-<?php
-// vim: foldmethod=marker
-/**
- *     Ethna_Plugin_Handle_UninstallPluginMaster.php
- *
- *  @author     ICHII Takashi <ichii386@schweetheart.jp>
- *     @license        http://www.opensource.org/licenses/bsd-license.php The BSD License
- *     @package        Ethna
- *     @version        $Id$
- */
-
-include_once(ETHNA_BASE . '/class/Ethna_PearWrapper.php');
-
-// {{{ Ethna_Plugin_Handle_UninstallPluginMaster
-/**
- *  uninstall-plugin-master handler
- *
- *  @author     ICHII Takashi <ichii386@schweetheart.jp>
- *     @access         public
- *     @package        Ethna
- */
-class Ethna_Plugin_Handle_UninstallPluginMaster extends Ethna_Plugin_Handle
-{
-    /**
-     *  get handler's description
-     *
-     *  @access public
-     */
-    function getDescription()
-    {
-        return "uninstall master plugin from Ethna directory:\n    {$this->id} [plugin type] [plugin name]\n";
-    }
-
-    /**
-     *  uninstall-plugin-master
-     *
-     *  @access public
-     */
-    function perform()
-    {
-        $r = $this->_validateArgList();
-        if (Ethna::isError($r)) {
-            return $r;
-        }
-        list($plugin_type, $plugin_name) = $r;
-        $package = "Ethna_Plugin_{$plugin_type}_{$plugin_name}";
-
-        // uninstall
-        $pear =& new Ethna_PearWrapper();
-        $r =& $pear->init('master');
-        if (Ethna::isError($r)) {
-            return $r;
-        }
-        $r =& $pear->doUninstall($package);
-        if (Ethna::isError($r)) {
-            return $r;
-        }
-
-        return true;
-    }
-
-    /**
-     *  show usage
-     *
-     *  @access public
-     */
-    function usage()
-    {
-        printf("usage:\nethna %s [plugin type] [plugin name]\n\n", $this->id);
-    }
-
-    /**
-     *  check arguments
-     *
-     *  @access private
-     */
-    function _validateArgList()
-    {
-        $arg_list = array();
-        if (count($this->arg_list) < 2) {
-            return Ethna::raiseError('too few arguments', 'usage');
-        } else if (count($this->arg_list) > 2) {
-            return Ethna::raiseError('too many arguments', 'usage');
-        } else {
-            $arg_list = $this->arg_list;
-        }
-
-        return $arg_list;
-    }
-}
-// }}}
-?>
index fbda785..04e0374 100644 (file)
@@ -47,6 +47,9 @@ class Ethna_View_Info extends Ethna_ViewClass
 
         // configuration
         $this->af->setApp('configuration', $em->getConfiguration());
+
+        // plugins
+        $this->af->setApp('plugin_list', $em->getPluginList());
     }
 }
 // }}}
index 199cf70..efb4593 100644 (file)
                                 {/foreach}
                                 </ol>
                             <li><a href="#configuration">Configuration</a></li>
+                            <li><a href="#plugins">Plugins</a></li>
+                                <ol>
+                                {foreach from=$app.plugin_list key=plugin_type item=plugin}
+                                    <li><a href="#plugin_{$plugin_type}">{$plugin_type}</a></li>
+                                {/foreach}
+                                </ol>
                         </ul>
                     </td>
                 </tr>
 
             <br />
 
+            <a name="plugins"></a>
+            <h1>Plugins</h1>
+
+            <table border="0" cellpadding="3" width="600">
+                {foreach from=$app.plugin_list key=plugin_type item=plugin}
+                <tr class="h">
+                    <th colspan="2">
+                        <a name="plugin_{$plugin_type}"></a>
+                        {$plugin_type}
+                    </th>
+                </tr>
+                    {foreach from=$plugin key=plugin_name item=plugin_class}
+                    <tr>
+                        <td class="e">{$plugin_name}</td>
+                        <td class="v">{$plugin_class}</td>
+                    </tr>
+                    {/foreach}
+                {/foreach}
+            </table>
+            <br />
+
             <hr />
             powered by <a href="http://ethna.jp/">Ethna {$app.ethna_version}</a> (experimental)
             <hr />