Skip to content

Commit

Permalink
up: sys, git - add new sys command, update the git branch command
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Aug 18, 2022
1 parent 95e1aa3 commit 30f6cfa
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 8 deletions.
38 changes: 32 additions & 6 deletions app/Console/Controller/SysController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,52 @@
namespace Inhere\Kite\Console\Controller;

use Inhere\Console\Controller;
use Inhere\Console\IO\Input;
use Inhere\Console\IO\Output;
use Toolkit\PFlag\FlagsParser;
use Toolkit\Sys\Sys;
use function array_merge;
use function glob;

/**
* Class DemoGroup
* Class SysController
*/
class SysController extends Controller
{
protected static string $name = 'sys';

protected static string $desc = 'Some useful tool commands for system';

protected static function commandAliases(): array
{
return [
'exeFind' => ['find', 'find-bin', 'find-exe'],
];
}

/**
* run a php built-in server for development(is alias of the command 'server:dev')
* search executable file in system PATH dirs.
*
* @param Input $input
* @arguments
* keywords string;The keywords for search;true
*
* @param FlagsParser $fs
* @param Output $output
*/
public function serveCommand(Input $input, Output $output): void
public function exeFindCommand(FlagsParser $fs, Output $output): void
{
$output->success('Complete');
$words = $fs->getArg('keywords');
$paths = Sys::getEnvPaths();
$output->aList($paths, "ENV PATH");

$result = [];
foreach ($paths as $path) {
$matches = glob($path. "/*$words*");
if ($matches) {
/** @noinspection SlowArrayOperationsInLoopInspection */
$result = array_merge($result, $matches);
}
}

$output->aList($result, 'RESULT');
}
}
8 changes: 6 additions & 2 deletions app/Console/SubCmd/Gitflow/BranchCreateCmd.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Inhere\Console\Command;
use Inhere\Console\IO\Input;
use Inhere\Console\IO\Output;
use Inhere\Kite\Common\Cmd;
use Inhere\Kite\Common\CmdRunner;
use Inhere\Kite\Helper\GitUtil;
use Inhere\Kite\Kite;
Expand Down Expand Up @@ -92,14 +91,19 @@ protected function execute(Input $input, Output $output): mixed
// ->afterOkRun("git push {$this->mainRemote} {$newBranch}");

$output->info('fetch latest information from remote: ' . $this->mainRemote);
Git::new()->fetch($this->mainRemote);
Git::new()->fetch($this->mainRemote, '', [
'no-tags' => true,
]);

// TODO git fetch main, git branch -a | grep $newBranch
$branches = GitUtil::matchBranch($newBranch);
if ($branches) {

}

// $repo = Repo::new();
// $repo->findBranch()

// $dryRun = true;
$dryRun = $fs->getOpt('dry-run');

Expand Down

0 comments on commit 30f6cfa

Please sign in to comment.