diff --git a/pear/Makefile.frag b/pear/Makefile.frag index 1395913117f..a1a352670a4 100644 --- a/pear/Makefile.frag +++ b/pear/Makefile.frag @@ -94,25 +94,29 @@ PEAR_FILES = \ # Net/Socket.php \ # Schedule/At.php \ -PEAR_PACKAGES=\ - Net_Socket-1.0.tgz - +#PEARCMD=$(top_builddir)/sapi/cli/php $(builddir)/scripts/pear +# +#install-pear-installer: $(top_builddir)/sapi/cli/php +# version=`grep '' $(srcdir)/package-pear.xml|head -1|cut -d\> -f2|cut -d\< -f1`; \ +# if $(PEARCMD) shell-test PEAR; then +# if ! $(PEARCMD) shell-test PEAR $$version; then \ +# $(PEARCMD) upgrade package-pear.xml; \ +# fi; \ +# else; \ +# $(PEARCMD) install package-pear.xml; \ +# fi install-pear: @if $(mkinstalldirs) $(INSTALL_ROOT)$(peardir); then \ for i in $(PEAR_SUBDIRS); do \ $(mkinstalldirs) $(INSTALL_ROOT)$(peardir)/$$i; \ done; \ - for dir in PEAR/CommandUI; do \ - test -d $(INSTALL_ROOT)$(peardir)/$$dir && rm -rf $(INSTALL_ROOT)$(peardir)/$$dir; \ - done; \ for i in $(PEAR_FILES); do \ echo "Installing $$i"; \ dir=`echo $$i|sed 's%[^/][^/]*$$%%'`; \ $(INSTALL_DATA) $(srcdir)/$$i $(INSTALL_ROOT)$(peardir)/$$dir; \ done; \ rm -f $(INSTALL_ROOT)$(peardir)/PEAR/Command/Login.php; \ - rm -f $(INSTALL_ROOT)$(peardir)/PEAR/CommandUI/CLI.php; \ rm -f $(INSTALL_ROOT)$(peardir)/PEAR/CommandResponse.php; \ rm -f $(INSTALL_ROOT)$(peardir)/PEAR/Uploader.php; \ else \ diff --git a/pear/PEAR/Command.php b/pear/PEAR/Command.php index b7f2b219237..7972f42eb53 100644 --- a/pear/PEAR/Command.php +++ b/pear/PEAR/Command.php @@ -197,8 +197,9 @@ class PEAR_Command include_once $file; // List of commands $implements = call_user_func(array($class, "getCommands")); - foreach ($implements as $command) { + foreach ($implements as $command => $desc) { $GLOBALS['_PEAR_Command_commandlist'][$command] = $class; + $GLOBALS['_PEAR_Command_commanddesc'][$command] = $desc; } // List of options accepted $cmdopts = array_merge($cmdopts, call_user_func(array($class, "getOptions"))); @@ -239,6 +240,20 @@ class PEAR_Command return $GLOBALS['_PEAR_Command_commandopts']; } + /** + * Get description for a command. + * + * @param string $command Name of the command + * + * @return string command description + * + * @access public + */ + function getDescription($command) + { + return @$GLOBALS['_PEAR_Command_commanddesc'][$command]; + } + /** * Get help for command. * diff --git a/pear/PEAR/Command/Auth.php b/pear/PEAR/Command/Auth.php index f59f730b83c..8632e95c624 100644 --- a/pear/PEAR/Command/Auth.php +++ b/pear/PEAR/Command/Auth.php @@ -51,7 +51,8 @@ class PEAR_Command_Auth extends PEAR_Command_Common */ function getCommands() { - return array('login', 'logout'); + return array('login' => 'Log In', + 'logout' => 'Log Out'); } // }}} diff --git a/pear/PEAR/Command/Config.php b/pear/PEAR/Command/Config.php index 009c2d243eb..c05389d4525 100644 --- a/pear/PEAR/Command/Config.php +++ b/pear/PEAR/Command/Config.php @@ -55,7 +55,9 @@ class PEAR_Command_Config extends PEAR_Command_Common */ function getCommands() { - return array('config-show', 'config-get', 'config-set'); + return array('config-show' => 'Show All Settings', + 'config-get' => 'Show One Setting', + 'config-set' => 'Change Setting'); } // }}} diff --git a/pear/PEAR/Command/Install.php b/pear/PEAR/Command/Install.php index a4efc90fd9a..cae832aec7d 100644 --- a/pear/PEAR/Command/Install.php +++ b/pear/PEAR/Command/Install.php @@ -51,7 +51,9 @@ class PEAR_Command_Install extends PEAR_Command_Common */ function getCommands() { - return array('install', 'uninstall', 'upgrade'); + return array('install' => 'Install Package', + 'uninstall' => 'Uninstall Package', + 'upgrade' => 'Upgrade Package'); } function getHelp($command) diff --git a/pear/PEAR/Command/Package.php b/pear/PEAR/Command/Package.php index 85bade842a9..e63b9cec913 100644 --- a/pear/PEAR/Command/Package.php +++ b/pear/PEAR/Command/Package.php @@ -67,11 +67,11 @@ class PEAR_Command_Package extends PEAR_Command_Common */ function getCommands() { - return array('package', - 'package-info', - 'package-list', - 'package-validate', - 'cvstag'); + return array('package' => 'Build Package', + 'package-info' => 'Show Package Info', + 'package-list' => 'List Files in Package', + 'package-validate' => 'Validate Package', + 'cvstag' => 'Set CVS Release Tag'); } // }}} diff --git a/pear/PEAR/Command/Registry.php b/pear/PEAR/Command/Registry.php index 049b89f54c8..be5bf182a8e 100644 --- a/pear/PEAR/Command/Registry.php +++ b/pear/PEAR/Command/Registry.php @@ -48,7 +48,8 @@ class PEAR_Command_Registry extends PEAR_Command_Common */ function getCommands() { - return array('list-installed', 'shell-test'); + return array('list-installed' => 'List Installed Packages', + 'shell-test' => 'Shell Script Test'); } function getHelp($command) diff --git a/pear/PEAR/Command/Remote.php b/pear/PEAR/Command/Remote.php index d9922021418..def57a4be19 100644 --- a/pear/PEAR/Command/Remote.php +++ b/pear/PEAR/Command/Remote.php @@ -48,10 +48,10 @@ class PEAR_Command_Remote extends PEAR_Command_Common */ function getCommands() { - return array('remote-package-info', - 'list-upgrades', - 'list-remote-packages', - 'download'); + return array('remote-package-info' => 'Information About Remote Package', + 'list-upgrades' => 'List Available Upgrades', + 'list-remote-packages' => 'List Remote Packages', + 'download' => 'Download Package'); } // }}} diff --git a/pear/PEAR/Frontend/Gtk.php b/pear/PEAR/Frontend/Gtk.php new file mode 100644 index 00000000000..f715fb41bb6 --- /dev/null +++ b/pear/PEAR/Frontend/Gtk.php @@ -0,0 +1,133 @@ + | + +----------------------------------------------------------------------+ + + $Id$ +*/ + +require_once "PEAR.php"; + +class PEAR_Frontend_Gtk extends PEAR +{ + // {{{ properties + + /** + * What type of user interface this frontend is for. + * @var string + * @access public + */ + var $type = 'Gtk'; + + var $omode = 'plain'; + var $params = array(); + var $window = null; + + // }}} + + // {{{ constructor + + function PEAR_Frontend_Gtk() + { + parent::PEAR(); + if (!extension_loaded('php_gtk')) { + dl('php_gtk.' . (OS_WINDOWS ? 'dll' : 'so')); + } + $this->window = &new GtkWindow(); + $this->window->set_title('PEAR Installer'); + $this->window->set_usize((gdk::screen_width()/3), (gdk::screen_height()/3)); + $this->window->show_all(); + } + + // }}} + + // {{{ displayLine(text) + + function displayLine($text) + { + } + + function display($text) + { + } + + // }}} + // {{{ displayError(eobj) + + function displayError($eobj) + { + } + + // }}} + // {{{ displayFatalError(eobj) + + function displayFatalError($eobj) + { + } + + // }}} + // {{{ displayHeading(title) + + function displayHeading($title) + { + } + + // }}} + // {{{ userDialog(prompt, [type], [default]) + + function userDialog($prompt, $type = 'text', $default = '') + { + } + + // }}} + // {{{ userConfirm(prompt, [default]) + + function userConfirm($prompt, $default = 'yes') + { + } + + // }}} + // {{{ startTable([params]) + + function startTable($params = array()) + { + } + + // }}} + // {{{ tableRow(columns, [rowparams], [colparams]) + + function tableRow($columns, $rowparams = array(), $colparams = array()) + { + } + + // }}} + // {{{ endTable() + + function endTable() + { + } + + // }}} + // {{{ bold($text) + + function bold($text) + { + } + + // }}} +} + +?> diff --git a/pear/package-pear.xml b/pear/package-pear.xml index d0516da0aef..ea26c4843e6 100644 --- a/pear/package-pear.xml +++ b/pear/package-pear.xml @@ -50,6 +50,7 @@ + diff --git a/pear/scripts/pear.in b/pear/scripts/pear.in index dc2561d16bc..4a386697729 100644 --- a/pear/scripts/pear.in +++ b/pear/scripts/pear.in @@ -33,19 +33,27 @@ require_once 'Console/Getopt.php'; PEAR_Command::setFrontendType('CLI'); $all_commands = PEAR_Command::getCommands(); $cmd_options = PEAR_Command::getOptions(); -$ui = &PEAR_Command::getFrontendObject(); $progname = basename(__FILE__); // XXX change Getopt to use raiseError() ? $argv = Console_Getopt::readPHPArgv(); -$options = Console_Getopt::getopt($argv, "c:C:d:D:h?sSqu:v" . $cmd_options); +$options = Console_Getopt::getopt($argv, "c:C:d:D:Gh?sSqu:v" . $cmd_options); if (PEAR::isError($options)) { usage($options); } -PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ui, "displayFatalError")); $opts = $options[0]; +$fetype = 'CLI'; +foreach ($opts as $opt) { + if ($opt[0] == 'G') { + $fetype = 'Gtk'; + } +} +PEAR_Command::setFrontendType($fetype); +$ui = &PEAR_Command::getFrontendObject(); +PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ui, "displayFatalError")); + $pear_user_config = ''; $pear_system_config = ''; $store_user_config = false; @@ -114,19 +122,23 @@ if (empty($command) && ($store_user_config || $store_system_config)) { exit; } -if (empty($all_commands[$command]) || $command == 'help') { - usage(null, @$options[1][2]); -} - -$cmd = PEAR_Command::factory($command, $config); -if (PEAR::isError($cmd)) { - die($cmd->getMessage()); -} - -$cmdargs = array_slice($options[1], 2); -$ok = $cmd->run($command, $cmdopts, $cmdargs); -if ($ok === false) { - PEAR::raiseError("unknown command `$command'"); +if ($fetype == 'Gtk') { + Gtk::main(); +} else { + if (empty($all_commands[$command]) || $command == 'help') { + usage(null, @$options[1][2]); + } + + $cmd = PEAR_Command::factory($command, $config); + if (PEAR::isError($cmd)) { + die($cmd->getMessage()); + } + + $cmdargs = array_slice($options[1], 2); + $ok = $cmd->run($command, $cmdopts, $cmdargs); + if ($ok === false) { + PEAR::raiseError("unknown command `$command'"); + } } // {{{ usage() @@ -148,9 +160,14 @@ function usage($error = null, $helpsubject = null) "Usage: $progname [options] command [command-options] \n". "Type \"$progname help options\" to list all options.\n". "Type \"$progname help \" to get the help for the specified command.\n". - "Commands:\n " . implode("\n ", array_keys($all_commands)); + "Commands:\n"; + $maxlen = max(array_map("strlen", $all_commands)); + $formatstr = "%-{$maxlen}s %s\n"; + foreach ($all_commands as $cmd => $class) { + $put .= sprintf($formatstr, $cmd, PEAR_Command::getDescription($cmd)); + } } - fputs($stderr, "$put\n\n"); + fputs($stderr, "$put\n"); fclose($stderr); exit; } @@ -167,6 +184,7 @@ function cmdHelp($command) " -C file find system configuration in `file'\n". " -d foo=bar set user config variable `foo' to `bar'\n". " -D foo=bar set system config variable `foo' to `bar'\n". + " -G start in graphical (Gtk) mode\n". " -s store user configuration\n". " -S store system configuration\n". " -u foo unset `foo' in the user configuration\n".