Added the ability to get the Argument cache and modify the regex pattern used

This commit is contained in:
Netkas 2023-01-27 00:22:14 -05:00
parent cbfc75e878
commit b3d7c7b9da

View file

@ -21,9 +21,16 @@
class Parse
{
/**
* The regex pattern to match options and arguments.
*
* @var string
*/
private static $Regex = "/(?(?=-)-(?(?=-)-(?'bigflag'[^\\s=]+)|(?'smallflag'\\S))(?:\\s*=\\s*|\\s+)(?(?!-)(?(?=[\\\"\\'])((?<![\\\\])['\"])(?'string'(?:.(?!(?<![\\\\])\\3))*.?)\\3|(?'value'\\S+)))(?:\\s+)?|(?'unmatched'\\S+))/";
/**
* Cache of the parsed arguments. This is used to prevent the arguments from being parsed more than once.
*
* @var array
*/
private static $ArgsCache;
@ -136,4 +143,32 @@
}
}
}
/**
* @return array
*/
public static function getArgsCache(): array
{
return self::$ArgsCache;
}
/**
* Gets the current regex pattern used to parse the arguments.
*
* @return string
*/
public static function getRegex(): string
{
return self::$Regex;
}
/**
* Sets a new regex pattern to use to parse the arguments.
*
* @param string $Regex
*/
public static function setRegex(string $Regex): void
{
self::$Regex = $Regex;
}
}