-
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: gitx - migrate the git tag list command to a command class.
- Loading branch information
Showing
3 changed files
with
92 additions
and
29 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
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,41 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Inhere\Kite\Console\SubCmd; | ||
|
||
use Inhere\Console\Command; | ||
use Inhere\Console\IO\Input; | ||
use Inhere\Console\IO\Output; | ||
use Inhere\Kite\Console\SubCmd\GitxCmd\GitTagListCmd; | ||
use Throwable; | ||
|
||
/** | ||
* class GitTagCmd | ||
* | ||
* @author inhere | ||
* @date 2022/7/12 | ||
*/ | ||
class GitTagCmd extends Command | ||
{ | ||
protected static string $name = 'tag'; | ||
protected static string $desc = 'git tag manage tool command. eg: list, add, del'; | ||
|
||
protected function subCommands(): array | ||
{ | ||
return [ | ||
GitTagListCmd::class, | ||
]; | ||
} | ||
|
||
/** | ||
* @param Input $input | ||
* @param Output $output | ||
* | ||
* @throws Throwable | ||
*/ | ||
protected function execute(Input $input, Output $output) | ||
{ | ||
// default run | ||
$bcCmd = new GitTagListCmd($input, $output); | ||
$bcCmd->run($this->flags->getFlags()); | ||
} | ||
} |
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,41 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Inhere\Kite\Console\SubCmd\GitxCmd; | ||
|
||
use Inhere\Console\Command; | ||
use Inhere\Console\IO\Input; | ||
use Inhere\Console\IO\Output; | ||
use Inhere\Kite\Common\CmdRunner; | ||
|
||
/** | ||
* class GitTagListCmd | ||
* | ||
* @author inhere | ||
* @date 2022/7/12 | ||
*/ | ||
class GitTagListCmd extends Command | ||
{ | ||
protected static string $name = 'list'; | ||
protected static string $desc = 'list git tags for project'; | ||
|
||
public static function aliases(): array | ||
{ | ||
return ['ls']; | ||
} | ||
|
||
protected function execute(Input $input, Output $output) | ||
{ | ||
$fs = $this->flags; | ||
|
||
// git tag --sort=-creatordate 倒序排列 | ||
$cmd = 'git tag -l -n2'; | ||
$kw = $fs->getArg(0); | ||
if ($kw) { | ||
$cmd .= " | grep $kw"; | ||
} | ||
|
||
CmdRunner::new($cmd)->do(true); | ||
|
||
$output->success('Complete'); | ||
} | ||
} |