Skip to content

Commit

Permalink
🐛 fix: args error for run a script
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Dec 27, 2021
1 parent 6d0a7ae commit 152accc
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 8 deletions.
28 changes: 28 additions & 0 deletions app/Console/Attach/Gitlab/MergeRequestCmd.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php declare(strict_types=1);

namespace Inhere\Kite\Console\Attach\Gitlab;

use Inhere\Console\Command;
use Inhere\Console\IO\Input;
use Inhere\Console\IO\Output;

/**
* class MergeRequestCmd
*
* @author inhere
*/
class MergeRequestCmd extends Command
{
/**
* Do execute command
*
* @param Input $input
* @param Output $output
*
* @return mixed
*/
protected function execute(Input $input, Output $output)
{
return 0;
}
}
11 changes: 6 additions & 5 deletions app/Console/Listener/NotFoundListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,25 @@ public function __invoke(string $cmd, CliApplication $app): bool
return true;
}

$sr = Kite::scriptRunner();
$ksr = Kite::scriptRunner();
$args = $app->getInput()->getFlags();

// - run custom scripts.
if ($sr->isScriptName($cmd)) {
if ($ksr->isScriptName($cmd)) {
array_shift($args); // first is script name.
$app->note("input is an script name, redirect to run script: $cmd, args: " . DataHelper::toString($args));
$sr->runScriptByName($cmd, $args);
$ksr->runScriptByName($cmd, $args);

} elseif (Kite::plugManager()->isPlugin($cmd)) { // - is an plugin
array_shift($args); // first is $cmd
$app->notice("input is an plugin name, will run plugin: $cmd, args: " . DataHelper::toString($args));

Kite::plugManager()->run($cmd, $app, $args);
} elseif ($sFile = $sr->findScriptFile($cmd)) { // - is script file
} elseif ($sFile = $ksr->findScriptFile($cmd)) { // - is script file
array_shift($args); // first is script file
$app->notice("input is an script file, will call it: $cmd, args: " . DataHelper::toString($args));

$sr->runScriptFile($sFile, $args);
$ksr->runScriptFile($sFile, $args);
} else {
// - call system command.
$this->callSystemCmd($cmd, $app);
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Plugin/AbstractPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public function getSimpleInfo(): array
protected function beforeRun(Application $app, array $args): bool
{
if ($this->fs->isNotEmpty()) {
$app->debugf('parse plugin flags, args: %s', DataHelper::toString($args));
$app->debugf('parse plugin %s flags, args: %s', $this->name, DataHelper::toString($args));
$ok = $this->fs->parse($args);

if (!$ok) {
Expand Down
2 changes: 1 addition & 1 deletion app/Console/more.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

## debain package search
## debian package search

- https://packages.debian.org/search

Expand Down
2 changes: 1 addition & 1 deletion resource/snippets/DemoGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DemoGroup extends Controller
{
protected static string $name = 'demo';

protected static string $description = 'Some useful development tool commands';
protected static string $desc = 'Some useful development tool commands';

/**
* run a php built-in server for development(is alias of the command 'server:dev')
Expand Down

0 comments on commit 152accc

Please sign in to comment.