-
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 the tool group command logic
- Loading branch information
Showing
13 changed files
with
120 additions
and
17 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
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
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
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,55 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Inhere\Kite\Console\SubCmd\ToolCmd; | ||
|
||
use Inhere\Console\Command; | ||
use Inhere\Console\IO\Input; | ||
use Inhere\Console\IO\Output; | ||
use Toolkit\Sys\Sys; | ||
|
||
/** | ||
* class FindExeCommand | ||
* | ||
* @author inhere | ||
*/ | ||
class FindExeCommand extends Command | ||
{ | ||
protected static string $name = 'find-exe'; | ||
protected static string $desc = 'search executable file in system PATH dirs.'; | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
public static function aliases(): array | ||
{ | ||
return ['find-bin']; | ||
} | ||
|
||
protected function configure(): void | ||
{ | ||
$this->flags->addArgByRule('keywords', 'string;The keywords for search;true'); | ||
// $this->flags->addOpt('show', 's', 'show the tool info', 'bool'); | ||
// $this->flags->addOpt('list', 'l', 'list all can be installed tools', 'bool'); | ||
} | ||
|
||
protected function execute(Input $input, Output $output) | ||
{ | ||
$fs = $this->flags; | ||
|
||
$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'); | ||
$output->info('TODO'); | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
app/Console/Command/SearchCommand.php → app/Console/SubCmd/ToolCmd/SearchCommand.php
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,40 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Inhere\Kite\Console\SubCmd\ToolCmd; | ||
|
||
use Inhere\Console\Command; | ||
use Inhere\Console\IO\Input; | ||
use Inhere\Console\IO\Output; | ||
|
||
/** | ||
* class LnCommand | ||
* | ||
* @author inhere | ||
*/ | ||
class SnippetCommand extends Command | ||
{ | ||
protected static string $name = 'snippet'; | ||
|
||
protected static string $desc = 'provide useful code snippet manage'; | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
public static function aliases(): array | ||
{ | ||
return ['snippets', 'snip']; | ||
} | ||
|
||
protected function configure(): void | ||
{ | ||
$this->flags->addArgByRule('name', 'show the tool detail info by name'); | ||
// $this->flags->addOpt('show', 's', 'show the tool info', 'bool'); | ||
// $this->flags->addOpt('list', 'l', 'list all can be installed tools', 'bool'); | ||
} | ||
|
||
protected function execute(Input $input, Output $output) | ||
{ | ||
|
||
$output->info('TODO'); | ||
} | ||
} |
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