OSDN Git Service

* rename plugin to comply with new naming convention
[ethna/ethna.git] / Idea_Plugin_Extlib / class / Plugin / Handle / AddAppObject.php
1 <?php
2 // vim: foldmethod=marker
3 /**
4  *  Ethna_Plugin_Handle_AddAppObject.php
5  *
6  *  @author     Masaki Fujimoto <fujimoto@php.net>
7  *  @license    http://www.opensource.org/licenses/bsd-license.php The BSD License
8  *  @package    Ethna
9  *  @version    $Id$
10  */
11
12 // {{{ Ethna_Plugin_Handle_AddAppObject
13 /**
14  *  add-app-object handler
15  *
16  *  @author     Masaki Fujimoto <fujimoto@php.net>
17  *  @access     public
18  *  @package    Ethna
19  */
20 class Ethna_Plugin_Handle_AddAppObject extends Ethna_Plugin_Handle
21 {
22     /**
23      *  add app-object
24      *
25      *  @access public
26      */
27     function perform()
28     {
29         return $this->_perform('AppObject');
30     }
31
32     /**
33      *  @access protected
34      */
35     function _perform($target)
36     {
37         $r =& $this->_getopt(array('basedir='));
38         if (Ethna::isError($r)) {
39             return $r;
40         }
41         list($opt_list, $arg_list) = $r;
42
43         // table_name
44         $table_name = array_shift($arg_list);
45         if ($table_name == null) {
46             return Ethna::raiseError('table name isn\'t set.', 'usage');
47         }
48
49         // basedir
50         if (isset($opt_list['basedir'])) {
51             $basedir = realpath(end($opt_list['basedir']));
52         } else {
53             $basedir = getcwd();
54         }
55
56         $r =& Ethna_Generator::generate($target, $basedir, $table_name);
57         if (Ethna::isError($r)) {
58             printf("error occurred while generating skelton. please see also following error message(s)\n\n");
59             return $r;
60         }
61
62         return true;
63     }
64
65     /**
66      *  get handler's description
67      *
68      *  @access public
69      */
70     function getDescription()
71     {
72         return <<<EOS
73 add new app-object to project:
74     {$this->id} [-b|--basedir=dir] [table name]
75
76 EOS;
77     }
78
79     /**
80      *  get usage
81      *
82      *  @access public
83      */
84     function getUsage()
85     {
86         return <<<EOS
87 ethna {$this->id} [-b|--basedir=dir] [table name]
88 EOS;
89     }
90 }
91 // }}}
92 ?>