Skip to content

Commit

Permalink
♻️ up: update the tool group command logic
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Jan 14, 2023
1 parent ea3dee3 commit d4e8c0d
Show file tree
Hide file tree
Showing 13 changed files with 120 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [8.1] # 7.2,7.4,8.0,
php: [8.1, 8.2] # 7.2,7.4,8.0,
os: [ubuntu-latest, macOS-latest] # windows-latest,
# include: # will not testing on php 7.2
# - os: 'ubuntu-latest'
Expand Down
20 changes: 14 additions & 6 deletions app/Console/Command/ToolCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@
use Inhere\Console\IO\Input;
use Inhere\Console\IO\Output;
use Inhere\Kite\Console\SubCmd\OpenCmd;
use Inhere\Kite\Console\SubCmd\ToolCmd\BatchCommand;
use Inhere\Kite\Console\SubCmd\ToolCmd\CatCommand;
use Inhere\Kite\Console\SubCmd\ToolCmd\ExprCommand;
use Inhere\Kite\Console\SubCmd\ToolCmd\FindCommand;
use Inhere\Kite\Console\SubCmd\ToolCmd\HashCommand;
use Inhere\Kite\Console\SubCmd\ToolCmd\HashHmacCommand;
use Inhere\Kite\Console\SubCmd\ToolCmd\InstallCommand;
use Inhere\Kite\Console\SubCmd\ToolCmd\ListToolCommand;
use Inhere\Kite\Console\SubCmd\ToolCmd\Json5Command;
use Inhere\Kite\Console\SubCmd\ToolCmd\LnCommand;
use Inhere\Kite\Console\SubCmd\ToolCmd\UpdateCommand;
use Inhere\Kite\Console\SubCmd\ToolCmd\MarkdownCommand;
use Inhere\Kite\Console\SubCmd\ToolCmd\SearchCommand;

/**
* Class ToolCommand
Expand All @@ -38,9 +42,13 @@ protected function subCommands(): array
LnCommand::class,
HashHmacCommand::class,
HashCommand::class,
InstallCommand::class,
UpdateCommand::class,
ListToolCommand::class,
Json5Command::class,
ExprCommand::class,
MarkdownCommand::class,
BatchCommand::class,
CatCommand::class,
FindCommand::class,
SearchCommand::class,
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @license MIT
*/

namespace Inhere\Kite\Console\Command;
namespace Inhere\Kite\Console\SubCmd\ToolCmd;

use Inhere\Console\Command;
use Inhere\Console\IO\Input;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @license MIT
*/

namespace Inhere\Kite\Console\Command;
namespace Inhere\Kite\Console\SubCmd\ToolCmd;

use Inhere\Console\Command;
use Inhere\Console\IO\Input;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @license MIT
*/

namespace Inhere\Kite\Console\Command;
namespace Inhere\Kite\Console\SubCmd\ToolCmd;

use Inhere\Console\Command;
use Inhere\Console\Component\Interact\IShell;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @license MIT
*/

namespace Inhere\Kite\Console\Command;
namespace Inhere\Kite\Console\SubCmd\ToolCmd;

use Inhere\Console\Command;
use Inhere\Console\IO\Input;
Expand Down
55 changes: 55 additions & 0 deletions app/Console/SubCmd/ToolCmd/FindExeCommand.php
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');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @license MIT
*/

namespace Inhere\Kite\Console\Command;
namespace Inhere\Kite\Console\SubCmd\ToolCmd;

use ColinODell\Json5\Json5Decoder;
use Inhere\Console\Command;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @license MIT
*/

namespace Inhere\Kite\Console\Command;
namespace Inhere\Kite\Console\SubCmd\ToolCmd;

use Inhere\Console\Command;
use Inhere\Console\IO\Input;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types=1);

namespace Inhere\Kite\Console\Command;
namespace Inhere\Kite\Console\SubCmd\ToolCmd;

use Inhere\Console\Command;
use Inhere\Console\IO\Input;
Expand Down
40 changes: 40 additions & 0 deletions app/Console/SubCmd/ToolCmd/SnippetCommand.php
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');
}
}
2 changes: 1 addition & 1 deletion app/Http/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ abstract class Controller
*/
protected function render(string $viewPath, array $vars = []): void
{
Kite::webApp()->getRenderer()->render($viewPath, $vars);
Kite::webApp()->getRenderer()->display($viewPath, $vars);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
'*'
],
// gitlab api config
'baseUrl' => '',
'baseApi' => '',
],
'github' => [
// remote
Expand All @@ -48,7 +48,7 @@
'*'
],
// github api config
// 'baseUrl' => '',
// 'baseApi' => '',
],
'osEnv' => [
// env settings
Expand Down

0 comments on commit d4e8c0d

Please sign in to comment.