Bearsampp 2026.9.23
Loading...
Searching...
No Matches
PEAR_Command_Common Class Reference
Inheritance diagram for PEAR_Command_Common:
Collaboration diagram for PEAR_Command_Common:

Public Member Functions

 __construct (&$ui, &$config)
 getCommands ()
 getGetoptArgs ($command, &$short_args, &$long_args)
 getHelp ($command)
 getHelpArgs ($command)
 getOptions ($command)
 getShortcuts ()
 run ($command, $options, $params)
Public Member Functions inherited from PEAR
 __call ($method, $arguments)
 __construct ($error_class=null)
 _checkDelExpect ($error_code)
 _PEAR ()
 delExpect ($error_code)
 expectError ($code=' *')
 PEAR ($error_class=null)
 popExpect ()

Data Fields

 $_deps_rel_trans
 $_deps_type_trans
 $_registry
 $config
 $ui
Data Fields inherited from PEAR
 $_debug = false
 $_default_error_handler = ''
 $_default_error_mode = null
 $_default_error_options = null
 $_error_class = 'PEAR_Error'
 $_expected_errors = array()

Additional Inherited Members

Static Public Member Functions inherited from PEAR
static __callStatic ($method, $arguments)
static getSourceDateEpoch ()
static & getStaticProperty ($class, $var)
static isError ($data, $code=null)
static loadExtension ($ext)
static registerShutdownFunc ($func, $args=array())
static staticPopErrorHandling ()
static staticPushErrorHandling ($mode, $options=null)
Static Protected Member Functions inherited from PEAR
static _popErrorHandling ($object)
static _pushErrorHandling ($object, $mode, $options=null)
static _raiseError ($object, $message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
static _setErrorHandling ( $object, $mode=null, $options=null)
static _throwError ($object, $message=null, $code=null, $userinfo=null)
Static Protected Attributes inherited from PEAR
static $bivalentMethods

Detailed Description

Definition at line 35 of file Common.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( & $ui,
& $config )

PEAR_Command_Common constructor.

@access public

Reimplemented in PEAR_Command_Auth, PEAR_Command_Build, PEAR_Command_Channels, PEAR_Command_Config, PEAR_Command_Install, PEAR_Command_Mirror, PEAR_Command_Package, PEAR_Command_Pickle, PEAR_Command_Registry, PEAR_Command_Remote, and PEAR_Command_Test.

Definition at line 83 of file Common.php.

84 {
85 parent::__construct();
86 $this->config = &$config;
87 $this->ui = &$ui;
88 }

References $config, and $ui.

Member Function Documentation

◆ getCommands()

getCommands ( )

Return a list of all the commands defined by this class.

Returns
array list of commands @access public

Definition at line 95 of file Common.php.

96 {
97 $ret = array();
98 foreach (array_keys($this->commands) as $command) {
99 $ret[$command] = $this->commands[$command]['summary'];
100 }
101
102 return $ret;
103 }
if( $raw) foreach($opts as $opt) if( $store_system_config) if($store_user_config) $command
Definition pearcmd.php:322

References $command.

◆ getGetoptArgs()

getGetoptArgs ( $command,
& $short_args,
& $long_args )

Definition at line 137 of file Common.php.

138 {
139 $short_args = '';
140 $long_args = array();
141 if (empty($this->commands[$command]) || empty($this->commands[$command]['options'])) {
142 return;
143 }
144
145 reset($this->commands[$command]['options']);
146 foreach ($this->commands[$command]['options'] as $option => $info) {
147 $larg = $sarg = '';
148 if (isset($info['arg'])) {
149 if ($info['arg'][0] == '(') {
150 $larg = '==';
151 $sarg = '::';
152 $arg = substr($info['arg'], 1, -1);
153 } else {
154 $larg = '=';
155 $sarg = ':';
156 $arg = $info['arg'];
157 }
158 }
159
160 if (isset($info['shortopt'])) {
161 $short_args .= $info['shortopt'] . $sarg;
162 }
163
164 $long_args[] = $option . $larg;
165 }
166 }

References $command.

◆ getHelp()

getHelp ( $command)

Returns the help message for the given command

Parameters
string$commandThe command
Returns
mixed A fail string if the command does not have help or a two elements array containing [0]=>help string, [1]=> help string for the accepted cmd args

Definition at line 176 of file Common.php.

177 {
178 $config = &PEAR_Config::singleton();
179 if (!isset($this->commands[$command])) {
180 return "No such command \"$command\"";
181 }
182
183 $help = null;
184 if (isset($this->commands[$command]['doc'])) {
185 $help = $this->commands[$command]['doc'];
186 }
187
188 if (empty($help)) {
189 // XXX (cox) Fallback to summary if there is no doc (show both?)
190 if (!isset($this->commands[$command]['summary'])) {
191 return "No help for command \"$command\"";
192 }
193 $help = $this->commands[$command]['summary'];
194 }
195
196 if (preg_match_all('/{config\s+([^\}]+)}/', $help, $matches)) {
197 foreach($matches[0] as $k => $v) {
198 $help = preg_replace("/$v/", $config->get($matches[1][$k]), $help);
199 }
200 }
201
202 return array($help, $this->getHelpArgs($command));
203 }
getHelpArgs($command)
Definition Common.php:211

References $command, $config, and getHelpArgs().

Referenced by PEAR_Command_Package\doCvsDiff(), PEAR_Command_Package\doCvsTag(), and PEAR_Command_Package\doSvnTag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getHelpArgs()

getHelpArgs ( $command)

Returns the help for the accepted arguments of a command

Parameters
string$command
Returns
string The help string

Definition at line 211 of file Common.php.

212 {
213 if (isset($this->commands[$command]['options']) &&
214 count($this->commands[$command]['options']))
215 {
216 $help = "Options:\n";
217 foreach ($this->commands[$command]['options'] as $k => $v) {
218 if (isset($v['arg'])) {
219 if ($v['arg'][0] == '(') {
220 $arg = substr($v['arg'], 1, -1);
221 $sapp = " [$arg]";
222 $lapp = "[=$arg]";
223 } else {
224 $sapp = " $v[arg]";
225 $lapp = "=$v[arg]";
226 }
227 } else {
228 $sapp = $lapp = "";
229 }
230
231 if (isset($v['shortopt'])) {
232 $s = $v['shortopt'];
233 $help .= " -$s$sapp, --$k$lapp\n";
234 } else {
235 $help .= " --$k$lapp\n";
236 }
237
238 $p = " ";
239 $doc = rtrim(str_replace("\n", "\n$p", $v['doc']));
240 $help .= " $doc\n";
241 }
242
243 return $help;
244 }
245
246 return null;
247 }

References $command.

Referenced by getHelp().

Here is the caller graph for this function:

◆ getOptions()

getOptions ( $command)

Definition at line 122 of file Common.php.

123 {
124 $shortcuts = $this->getShortcuts();
125 if (isset($shortcuts[$command])) {
126 $command = $shortcuts[$command];
127 }
128
129 if (isset($this->commands[$command]) &&
130 isset($this->commands[$command]['options'])) {
131 return $this->commands[$command]['options'];
132 }
133
134 return null;
135 }

References $command, and getShortcuts().

Here is the call graph for this function:

◆ getShortcuts()

getShortcuts ( )

Return a list of all the command shortcuts defined by this class.

Returns
array shortcut => command @access public

Definition at line 110 of file Common.php.

111 {
112 $ret = array();
113 foreach (array_keys($this->commands) as $command) {
114 if (isset($this->commands[$command]['shortcut'])) {
115 $ret[$this->commands[$command]['shortcut']] = $command;
116 }
117 }
118
119 return $ret;
120 }

References $command.

Referenced by getOptions().

Here is the caller graph for this function:

◆ run()

run ( $command,
$options,
$params )

Definition at line 249 of file Common.php.

250 {
251 if (empty($this->commands[$command]['function'])) {
252 // look for shortcuts
253 foreach (array_keys($this->commands) as $cmd) {
254 if (isset($this->commands[$cmd]['shortcut']) && $this->commands[$cmd]['shortcut'] == $command) {
255 if (empty($this->commands[$cmd]['function'])) {
256 return $this->raiseError("unknown command `$command'");
257 } else {
258 $func = $this->commands[$cmd]['function'];
259 }
260 $command = $cmd;
261
262 //$command = $this->commands[$cmd]['function'];
263 break;
264 }
265 }
266 } else {
267 $func = $this->commands[$command]['function'];
268 }
269
270 return $this->$func($command, $options, $params);
271 }
$options
Definition pearcmd.php:145

References $command, and $options.

Field Documentation

◆ $_deps_rel_trans

$_deps_rel_trans
Initial value:
= array(
'lt' => '<',
'le' => '<=',
'eq' => '=',
'ne' => '!=',
'gt' => '>',
'ge' => '>=',
'has' => '=='
)

Definition at line 56 of file Common.php.

◆ $_deps_type_trans

$_deps_type_trans
Initial value:
= array(
'pkg' => 'package',
'ext' => 'extension',
'php' => 'PHP',
'prog' => 'external program',
'ldlib' => 'external library for linking',
'rtlib' => 'external runtime library',
'os' => 'operating system',
'websrv' => 'web server',
'sapi' => 'SAPI backend'
)

Definition at line 66 of file Common.php.

◆ $_registry

$_registry

Definition at line 48 of file Common.php.

◆ $config

◆ $ui


The documentation for this class was generated from the following file:
  • E:/Bearsampp-development/sandbox/core/libs/php/pear/pear/PEAR/Command/Common.php