function System::_parseArgs
returns the commandline arguments of a function
Parameters
string $argv the commandline:
string $short_options the allowed option short-tags:
string $long_options the allowed option long-tags:
Return value
array the given options and there values
3 calls to System::_parseArgs()
- System::mkDir in vendor/
pear/ pear-core-minimal/ src/ System.php - Make directories.
- System::mktemp in vendor/
pear/ pear-core-minimal/ src/ System.php - Creates temporary files or directories. This function will remove the created files when the scripts finish its execution.
- System::rm in vendor/
pear/ pear-core-minimal/ src/ System.php - The rm command for removing files. Supports multiple files and dirs and also recursive deletes
File
-
vendor/
pear/ pear-core-minimal/ src/ System.php, line 68
Class
- System
- System offers cross platform compatible system functions
Code
public static function _parseArgs($argv, $short_options, $long_options = null) {
if (!is_array($argv) && $argv !== null) {
/*
// Quote all items that are a short option
$av = preg_split('/(\A| )--?[a-z0-9]+[ =]?((?<!\\\\)((,\s*)|((?<!,)\s+))?)/i', $argv, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE);
$offset = 0;
foreach ($av as $a) {
$b = trim($a[0]);
if ($b[0] == '"' || $b[0] == "'") {
continue;
}
$escape = escapeshellarg($b);
$pos = $a[1] + $offset;
$argv = substr_replace($argv, $escape, $pos, strlen($b));
$offset += 2;
}
*/
// Find all items, quoted or otherwise
preg_match_all("/(?:[\"'])(.*?)(?:['\"])|([^\\s]+)/", $argv, $av);
$argv = $av[1];
foreach ($av[2] as $k => $a) {
if (empty($a)) {
continue;
}
$argv[$k] = trim($a);
}
}
return Console_Getopt::getopt2($argv, $short_options, $long_options);
}