Permalink
Browse files

Updated doc blocks

  • Loading branch information...
WyriHaximus committed Sep 16, 2013
1 parent cdf2b8c commit 79202ad8a0b36fec8f8db4c0c567b55d79335496
View
@@ -1,50 +0,0 @@
-# bash completion for CakePHP console
-
-_cake()
-{
- local cur prev opts cake
- COMPREPLY=()
- cake="${COMP_WORDS[0]}"
- cur="${COMP_WORDS[COMP_CWORD]}"
- prev="${COMP_WORDS[COMP_CWORD-1]}"
-
- if [[ "$cur" == -* ]] ; then
- if [[ ${COMP_CWORD} = 1 ]] ; then
- opts=$(${cake} Completion options)
- elif [[ ${COMP_CWORD} = 2 ]] ; then
- opts=$(${cake} Completion options "${COMP_WORDS[1]}")
- else
- opts=$(${cake} Completion options "${COMP_WORDS[1]}" "${COMP_WORDS[2]}")
- fi
-
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- fi
-
- if [[ ${COMP_CWORD} = 1 ]] ; then
- opts=$(${cake} Completion commands)
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- fi
-
- if [[ ${COMP_CWORD} = 2 ]] ; then
- opts=$(${cake} Completion subcommands $prev)
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- if [[ $COMPREPLY = "" ]] ; then
- COMPREPLY=( $(compgen -df -- ${cur}) )
- return 0
- fi
- return 0
- fi
-
-
- opts=$(${cake} Completion fuzzy "${COMP_WORDS[@]:1}")
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- if [[ $COMPREPLY = "" ]] ; then
- COMPREPLY=( $(compgen -df -- ${cur}) )
- return 0
- fi
- return 0;
-}
-
-complete -F _cake cake Console/cake
@@ -1,27 +1,49 @@
<?php
+/**
+ * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
+ * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
+ *
+ * Licensed under The MIT License
+ * For full copyright and license information, please see the LICENSE.txt
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
+ * @link http://cakephp.org CakePHP Project
+ * @package Cake.Console.Command
+ * @since CakePHP v 2.5
+ * @license http://www.opensource.org/licenses/mit-license.php MIT License
+ */
+
App::uses('CommandListShell', 'Console/Command');
/**
- * CompletionShell
+ * Provide command completion shells such as bash.
+ *
+ * @package Cake.Console.Command
*/
class CompletionShell extends CommandListShell {
/**
- * Echo no header
+ * Echo no header by overriding the startup method
*
+ * @return void
*/
public function startup() {
}
/**
- * Not called by the autocomplet shell - this is for curious users
+ * Not called by the autocomplete shell - this is for curious users
+ *
+ * @return void
*/
public function main() {
- $this->out($this->OptionParser->help());
+ return $this->out($this->OptionParser->help());
}
/**
* list commands
+ *
+ * @return void
*/
public function commands() {
$options = $this->_commands();
@@ -30,6 +52,8 @@ public function commands() {
/**
* list options for the named command
+ *
+ * @return void
*/
public function options() {
if (!$this->args) {
@@ -57,6 +81,8 @@ public function options() {
/**
* list subcommands for the named command
+ *
+ * @return void
*/
public function subCommands() {
if (!$this->args) {
@@ -69,13 +95,17 @@ public function subCommands() {
/**
* Guess autocomplete from the whole argument string
+ *
+ * @return void
*/
public function fuzzy() {
return $this->_output();
}
/**
* getOptionParser for _this_ shell
+ *
+ * @return ConsoleOptionParser
*/
public function getOptionParser() {
$translationDomain = 'bash_completion';
@@ -186,19 +216,22 @@ protected function _subCommands($commandName) {
}
/**
- * _getShell
+ * Get Shell instance for the given command
*
* @param mixed $commandName
+ * @return mixed
*/
protected function _getShell($commandName) {
list($plugin, $name) = pluginSplit($commandName, true);
+ if ($plugin === 'CORE.' || $plugin === 'APP.' || $plugin === 'core.' || $plugin === 'app.') {
+ $commandName = $name;
+ $plugin = '';
+ }
+
if (!in_array($commandName, $this->_commands())) {
return false;
}
- if ($plugin === 'CORE.' || $plugin === 'APP.') {
- $plugin = '';
- }
$name = Inflector::camelize($name);
$plugin = Inflector::camelize($plugin);
@@ -217,10 +250,11 @@ protected function _getShell($commandName) {
* Emit results as a string, space delimited
*
* @param array $options
+ * @return void
*/
protected function _output($options = array()) {
if ($options) {
- $this->out(implode($options, ' '));
+ return $this->out(implode($options, ' '));
}
}
}
@@ -98,7 +98,7 @@ public function testMain() {
$expected = "/\[.*TestPluginTwo.*\] example, welcome/";
$this->assertRegExp($expected, $output);
- $expected = "/\[.*CORE.*\] acl, api, bake, command_list, console, i18n, schema, server, test, testsuite, upgrade/";
+ $expected = "/\[.*CORE.*\] acl, api, bake, command_list, completion, console, i18n, schema, server, test, testsuite, upgrade/";
$this->assertRegExp($expected, $output);
$expected = "/\[.*app.*\] sample/";
Oops, something went wrong.

0 comments on commit 79202ad

Please sign in to comment.