@@ -60,7 +60,7 @@ public function initialize() {
60
60
*/
61
61
public function main () {
62
62
if (empty ($ this ->args )) {
63
- return $ this ->help ();
63
+ return $ this ->out ( $ this -> OptionParser -> help () );
64
64
}
65
65
66
66
$ type = strtolower ($ this ->args [0 ]);
@@ -78,7 +78,6 @@ public function main() {
78
78
$ file = Inflector::underscore ($ this ->args [1 ]);
79
79
$ class = Inflector::camelize ($ file );
80
80
}
81
-
82
81
$ objects = App::objects ('class ' , $ path );
83
82
if (in_array ($ class , $ objects )) {
84
83
if (in_array ($ type , array ('behavior ' , 'component ' , 'helper ' )) && $ type !== $ file ) {
@@ -88,19 +87,18 @@ public function main() {
88
87
}
89
88
90
89
} else {
91
- $ this ->err (sprintf (__ ('%s not found ' ), $ class ));
92
- $ this ->_stop ();
90
+ $ this ->error (sprintf (__ ('%s not found ' ), $ class ));
93
91
}
94
92
95
93
$ parsed = $ this ->__parseClass ($ path . $ file .'.php ' , $ class );
96
94
97
95
if (!empty ($ parsed )) {
98
- if (isset ($ this ->params ['m ' ])) {
99
- if (!isset ($ parsed [$ this ->params ['m ' ]])) {
100
- $ this ->err (sprintf (__ ('%s::%s() could not be found ' ), $ class , $ this ->params ['m ' ]));
96
+ if (isset ($ this ->params ['method ' ])) {
97
+ if (!isset ($ parsed [$ this ->params ['method ' ]])) {
98
+ $ this ->err (sprintf (__ ('%s::%s() could not be found ' ), $ class , $ this ->params ['method ' ]));
101
99
$ this ->_stop ();
102
100
}
103
- $ method = $ parsed [$ this ->params ['m ' ]];
101
+ $ method = $ parsed [$ this ->params ['method ' ]];
104
102
$ this ->out ($ class .':: ' .$ method ['method ' ] . $ method ['parameters ' ]);
105
103
$ this ->hr ();
106
104
$ this ->out ($ method ['comment ' ], true );
@@ -136,6 +134,23 @@ public function main() {
136
134
}
137
135
}
138
136
137
+ /**
138
+ * Get and configure the optionparser.
139
+ *
140
+ * @return ConsoleOptionParser
141
+ */
142
+ protected function _getOptionParser () {
143
+ $ parser = parent ::_getOptionParser ();
144
+ $ parser ->addArgument ('type ' , array (
145
+ 'help ' => 'Either a full path or type of class (model, behavior, controller, component, view, helper) '
146
+ ))->addArgument ('className ' , array (
147
+ 'help ' => 'A CakePHP core class name (e.g: Component, HtmlHelper). '
148
+ ))->addOption ('method ' , array (
149
+ 'short ' => 'm ' ,
150
+ 'help ' => __ ('The specific method you want help on. ' )
151
+ ))->description (__ ('Lookup doc block comments for classes in CakePHP. ' ));
152
+ return $ parser ;
153
+ }
139
154
/**
140
155
* Show help for this shell.
141
156
*
0 commit comments