add builder() and patch_point() global functions

This commit is contained in:
crazywhalecc 2024-01-09 10:35:14 +08:00 committed by Jerry Ma
parent 7620d5900e
commit fdc00301c0
2 changed files with 23 additions and 1 deletions

View File

@ -43,7 +43,7 @@ class BuilderProvider
/** /**
* @throws WrongUsageException * @throws WrongUsageException
*/ */
public function getBuilder(): BuilderBase public static function getBuilder(): BuilderBase
{ {
if (self::$builder === null) { if (self::$builder === null) {
throw new WrongUsageException('Builder has not been initialized'); throw new WrongUsageException('Builder has not been initialized');

View File

@ -3,6 +3,8 @@
declare(strict_types=1); declare(strict_types=1);
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use SPC\builder\BuilderBase;
use SPC\builder\BuilderProvider;
use SPC\exception\RuntimeException; use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException; use SPC\exception\WrongUsageException;
use SPC\util\UnixShell; use SPC\util\UnixShell;
@ -127,3 +129,23 @@ function cmd(?bool $debug = null): WindowsCmd
{ {
return new WindowsCmd($debug); return new WindowsCmd($debug);
} }
/**
* Get current builder.
*
* @throws WrongUsageException
*/
function builder(): BuilderBase
{
return BuilderProvider::getBuilder();
}
/**
* Get current patch point.
*
* @throws WrongUsageException
*/
function patch_point(): string
{
return BuilderProvider::getBuilder()->getPatchPoint();
}