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
pull/2/head
Christian Boltz 11 years ago
parent 72f0818391
commit 9decae80e9

@ -97,20 +97,6 @@ class PostfixAdmin {
* @access public * @access public
*/ */
var $shellCommand = null; 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. * The name of the shell in camelized.
* *
@ -174,7 +160,6 @@ class PostfixAdmin {
if (basename(__FILE__) != basename($this->args[0])) { 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...'); $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') { if ($this->getInput('Continue anyway?', array('y', 'n'), 'y') == 'n') {
exit(); exit();
@ -203,18 +188,10 @@ class PostfixAdmin {
return false; 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(PATH . '/common.php')) {
if (!require_once($inc)) { $this->stderr("Failed to load " . PATH . '/common.php');
$this->stderr("Failed to load {$inc}"); return false;
return false;
}
} }
return true; return true;
@ -260,7 +237,7 @@ class PostfixAdmin {
} }
if (!class_exists($this->shellClass)) { if (!class_exists($this->shellClass)) {
$this->stderr('Class '.$this->shellClass.' could not be loaded'); $this->stderr('Unknown task ' . $this->shellCommand);
return; return;
} }
@ -269,7 +246,7 @@ class PostfixAdmin {
$shell->handler_to_use = ucfirst($this->shell) . 'Handler'; $shell->handler_to_use = ucfirst($this->shell) . 'Handler';
if (!class_exists($shell->handler_to_use)) { 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; return;
} }
@ -504,7 +481,7 @@ class PostfixAdmin {
function commands() { function commands() {
# TODO: this list is incomplete
return array( return array(
'mailbox' => array( 'mailbox' => array(
'add'=> 'Adds a new mailbox.', 'add'=> 'Adds a new mailbox.',

@ -44,14 +44,6 @@ class Shell {
* @access public * @access public
*/ */
var $interactive = true; 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. * Contains command switches parsed from the command line.
* *
@ -94,20 +86,7 @@ class Shell {
* @access public * @access public
*/ */
var $name = null; 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. * Constructs this Shell instance.
* *
@ -161,8 +140,6 @@ if ( empty($this->params['q'] ) ) {
*/ */
function _welcome() { function _welcome() {
$this->out("\nWelcome to Postfixadmin-CLI v" . $this->Dispatch->version); $this->out("\nWelcome to Postfixadmin-CLI v" . $this->Dispatch->version);
$this->out("---------------------------------------------------------------");
$this->out('Path: '. PATH);
$this->hr(); $this->hr();
} }

Loading…
Cancel
Save