From 9decae80e903a7b44bd9ea72e25b3a486124546b Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Thu, 14 Nov 2013 21:48:52 +0000 Subject: [PATCH] some CLI cleanup postfixadmin-cli.php: - better error message for unknown modules or tasks - remove unused variables - __bootstrap(): require_once() common.php is enough (and inflector.php no longer exists) shells/shell.php: - remove unused variables - no longer print the path in _welcome() git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1578 a1433add-5e2c-0410-b055-b7f2511e0802 --- scripts/postfixadmin-cli.php | 35 ++++++----------------------------- scripts/shells/shell.php | 25 +------------------------ 2 files changed, 7 insertions(+), 53 deletions(-) diff --git a/scripts/postfixadmin-cli.php b/scripts/postfixadmin-cli.php index 3a2e3dab..d9d2b829 100644 --- a/scripts/postfixadmin-cli.php +++ b/scripts/postfixadmin-cli.php @@ -97,20 +97,6 @@ class PostfixAdmin { * @access public */ var $shellCommand = null; -/** - * The path locations of shells. - * - * @var array - * @access public - */ - var $shellPaths = array(); -/** - * The path to the current shell location. - * - * @var string - * @access public - */ - var $shellPath = null; /** * The name of the shell in camelized. * @@ -174,7 +160,6 @@ class PostfixAdmin { if (basename(__FILE__) != basename($this->args[0])) { - $this->stderr("\nCakePHP Console: "); $this->stderr('Warning: the dispatcher may have been loaded incorrectly, which could lead to unexpected results...'); if ($this->getInput('Continue anyway?', array('y', 'n'), 'y') == 'n') { exit(); @@ -203,18 +188,10 @@ class PostfixAdmin { return false; } - $includes = array( - PATH.'/config.inc.php', - PATH.'/functions.inc.php', - PATH.'/common.php', - CORE_INCLUDE_PATH.'/inflector.php', - ); - foreach ($includes as $inc) { - if (!require_once($inc)) { - $this->stderr("Failed to load {$inc}"); - return false; - } + if (!require_once(PATH . '/common.php')) { + $this->stderr("Failed to load " . PATH . '/common.php'); + return false; } return true; @@ -260,7 +237,7 @@ class PostfixAdmin { } if (!class_exists($this->shellClass)) { - $this->stderr('Class '.$this->shellClass.' could not be loaded'); + $this->stderr('Unknown task ' . $this->shellCommand); return; } @@ -269,7 +246,7 @@ class PostfixAdmin { $shell->handler_to_use = ucfirst($this->shell) . 'Handler'; if (!class_exists($shell->handler_to_use)) { - $this->stderr('Class '.$shell->handler_to_use.' could not be loaded'); + $this->stderr('Unknown module ' . $this->shell); return; } @@ -504,7 +481,7 @@ class PostfixAdmin { function commands() { - +# TODO: this list is incomplete return array( 'mailbox' => array( 'add'=> 'Adds a new mailbox.', diff --git a/scripts/shells/shell.php b/scripts/shells/shell.php index 9de37b45..35126288 100644 --- a/scripts/shells/shell.php +++ b/scripts/shells/shell.php @@ -44,14 +44,6 @@ class Shell { * @access public */ var $interactive = true; -/** - * Holds the DATABASE_CONFIG object for the app. Null if database.php could not be found, - * or the app does not exist. - * - * @var object - * @access public - */ - var $DbConfig = null; /** * Contains command switches parsed from the command line. * @@ -94,20 +86,7 @@ class Shell { * @access public */ var $name = null; -/** - * Contains tasks to load and instantiate - * - * @var array - * @access public - */ - var $tasks = array(); -/** - * Contains models to load and instantiate - * - * @var array - * @access public - */ - var $uses = array(); + /** * Constructs this Shell instance. * @@ -161,8 +140,6 @@ if ( empty($this->params['q'] ) ) { */ function _welcome() { $this->out("\nWelcome to Postfixadmin-CLI v" . $this->Dispatch->version); - $this->out("---------------------------------------------------------------"); - $this->out('Path: '. PATH); $this->hr(); }