cvs: php4 /pear/PEAR/Command Config.php
| From: | Tomas V.V.Cox | Date: | Mon, 01 Apr 2002 18:19:45 +0000 |
| Subject: | cvs: php4 /pear/PEAR/Command Config.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-2962@lists.php.net to get a copy of this message | ||
cox Mon Apr 1 13:19:45 2002 EDT
Modified files:
/php4/pear/PEAR/Command Config.php
Log:
- Make "config-set" actually store the values
- Help and error messages enhance
Index: php4/pear/PEAR/Command/Config.php
diff -u php4/pear/PEAR/Command/Config.php:1.6 php4/pear/PEAR/Command/Config.php:1.7
--- php4/pear/PEAR/Command/Config.php:1.6 Mon Apr 1 10:23:46 2002
+++ php4/pear/PEAR/Command/Config.php Mon Apr 1 13:19:45 2002
@@ -16,7 +16,7 @@
// | Author: Stig Bakken <ssb@fast.no> |
// +----------------------------------------------------------------------+
//
-// $Id: Config.php,v 1.6 2002/04/01 15:23:46 cox Exp $
+// $Id: Config.php,v 1.7 2002/04/01 18:19:45 cox Exp $
require_once "PEAR/Command/Common.php";
require_once "PEAR/Config.php";
@@ -62,14 +62,21 @@
{
switch ($command) {
case 'config-show':
- return array(null, 'Displays the configuration');
+ $ret = array('[<layer>]', 'Displays the configuration');
+ break;
case 'config-get':
- return array('<parameter>',
+ $ret = array('<parameter> [<layer>]',
'Displays the value of the given parameter');
+ break;
case 'config-set':
- return array('<parameter>=<value>',
+ $ret = array('<parameter> <value> [<layer>]',
'Sets the value of a parameter in the config');
+ break;
}
+ $ret[1] .= "\n".
+ " <layer> Where to store/get the configuration. The
installer\n".
+ " supports 'user' (per user conf) and
'system' (global conf)";
+ return $ret;
}
// {{{ run()
@@ -77,8 +84,6 @@
{
$cf =& $this->config;
$failmsg = '';
- $params[0] = (isset($params[0])) ? $params[0] : null;
- $params[1] = (isset($params[1])) ? $params[1] : null;
switch ($command) {
case 'config-show': {
$keys = $cf->getKeys();
@@ -96,7 +101,7 @@
} else {
foreach ($keys as $key) {
$type = $cf->getType($key);
- $value = $cf->get($key, $params[0]);
+ $value = $cf->get($key, @$params[0]);
if ($type == 'password' && $value) {
$value = '********';
}
@@ -108,7 +113,7 @@
}
case 'config-get': {
if (sizeof($params) < 1 || sizeof($params) > 2) {
- $failmsg .= "config-get expects 1 or 2 parameters";
+ $failmsg .= "config-get expects 1 or 2 parameters. Try \"help
config-get\" for help";
} elseif (sizeof($params) == 1) {
$this->ui->displayLine("$params[0] = " .
$cf->get($params[0]));
} else {
@@ -119,13 +124,15 @@
}
case 'config-set': {
if (sizeof($params) < 2 || sizeof($params) > 3) {
- $failmsg .= "config-set expects 2 or 3 parameters";
+ $failmsg .= "config-set expects 2 or 3 parameters. Try \"help
config-set\" for help";
break;
} else {
- if (!call_user_func_array(array($cf, 'set'), $params))
+ if (!call_user_func_array(array(&$cf, 'set'), $params))
{
$failmsg = "config-set (" .
implode(", ", $params) . ") failed";
+ } else {
+ $cf->store();
}
}
break;