0
0
mirror of https://github.com/postfixadmin/postfixadmin.git synced 2024-09-20 03:36:20 +02:00
postfixadmin/model/CliHelp.php
Christian Boltz c65e3293b6 Quite big CLI cleanup (and more)
model/CliHelp.php:
- new class, used for "postfixadmin-cli $module help"
- replaces the PostfixAdmin* classes in scripts/shells/*.php

model/PFAHandler.php
- add public $taskNames with the list of supported CLI commands

scripts/postfixadmin-cli.php - dispatch():
- directly set the classes to load instead of using shell->loadTasks()
- when "postfixadmin-cli $module" is called, display help instead of 
  error message about "invalid command ''"
- make it more readable by moving error checks to the beginning
  (replaces deeply nested if's with return statements)
- remove unused code parts

scripts/shells/*.php:
- remove PostfixAdmin* classes (obsoleted by CliHelp)
- remove $tasks (now in PFAHandler)
- delete alias.php and domain.php because nothing is left
- mailbox.php still contains PasswordTask

scripts/shells/shell.php:
- remove $taskNames (moved to PFAHandler)
- remove loadTasks() (integrated in postfixadmin-cli.php's dispatch())



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1575 a1433add-5e2c-0410-b055-b7f2511e0802
2013-11-13 19:07:12 +00:00

66 lines
1.8 KiB
PHP

<?php
class CliHelp extends Shell {
public $handler_to_use = "__not_set__";
/**
* Show help for this shell.
*
* @access public
*/
public function execute() {
$this->help();
}
public function help() {
$handler = new $this->handler_to_use;
# TODO: adjust help text according to $handler->taskNames
$module = preg_replace('/Handler$/', '', $this->handler_to_use);
$module = strtolower($module);
$this->out(
"Usage:
postfixadmin-cli $module <task> [<address>] [--option value]
");
/*
View $module in interactive mode.
- or -
postfixadmin-cli $module view <address>
View $module <address> in non-interactive mode.
"); */
$head = "Usage: postfixadmin-cli $module <task> [<address>] [--option value] [--option value]\n";
$head .= "-----------------------------------------------\n";
$head .= "Parameters:\n\n";
$commands = array(
'task' => "\t<task>\n" .
"\t\tAvailable values:\n\n".
"\t\t".sprintf("%-20s %s", "view: ", "View an existing $module.")."\n".
"\t\t".sprintf("%-20s %s", "add: ", "Add a $module.")."\n".
"\t\t".sprintf("%-20s %s", "update: ", "Update a $module.")."\n".
"\t\t".sprintf("%-20s %s", "delete: ", "Delete a $module")."\n".
"\t\t".sprintf("%-20s %s", "password: ", "Changes the password for a $module")."\n",
'address' => "\t[<address>]\n" .
"\t\tA address of recipient.\n",
);
foreach ($commands as $cmd) {
$this->out("{$cmd}\n\n");
}
}
}
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */