-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
up: update redirect to git commands logic
- Loading branch information
Showing
3 changed files
with
85 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Inhere\Kite\Console\Component; | ||
|
||
use Inhere\Console\Application; | ||
use Inhere\Console\Console; | ||
use Inhere\Kite\Console\Controller\GitController; | ||
use Throwable; | ||
use Toolkit\Cli\Cli; | ||
use Toolkit\Stdlib\Obj\AbstractObj; | ||
use function in_array; | ||
|
||
/** | ||
* class RedirectToGitGroup | ||
*/ | ||
class RedirectToGitGroup extends AbstractObj | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
public $cmdList = []; | ||
|
||
/** | ||
* @param Application $app | ||
* @param string $action | ||
* @param array $args | ||
* | ||
* @return bool | ||
* @throws Throwable | ||
*/ | ||
public function handle(Application $app, string $action, array $args):bool | ||
{ | ||
// resolve alias | ||
$gitCtrl = $app->getController(GitController::getName()); | ||
$command = $gitCtrl->resolveAlias($action); | ||
|
||
$redirectList = $this->cmdList; | ||
if (in_array($command, $redirectList, true)) { | ||
Cli::info("NOTICE: will redirect to git group for run `git $command`"); | ||
// Console::app()->dispatch("git:$command"); | ||
// Console::app()->dispatch("git:$command", $this->flags->getRawArgs()); | ||
Console::app()->dispatch("git:$command", $args); | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters