[fix] Command argv parse error

This commit is contained in:
Lkeme 2022-09-10 17:12:51 +08:00
parent 5b814434a8
commit 924c71ad9e
3 changed files with 21 additions and 6 deletions

View File

@ -63,6 +63,10 @@ final class DebugCommand extends Command
{
Log::info("执行 $this->desc");
//
if (is_null($this->values()['plugin']) || $this->values()['plugins']) {
failExit('发生错误,未加载插件');
}
//
$p = $this->values()['plugin'];
if (is_null($p)) {
$temp = $this->values()['plugins'];
@ -76,7 +80,7 @@ final class DebugCommand extends Command
//
$plugins = Plugin::getPlugins();
foreach ($plugins as $plugin) {
if(!in_array($plugin['hook'],$pp)){
if (!in_array($plugin['hook'], $pp)) {
continue;
}
Task::addTask($plugin['hook'], null);
@ -85,5 +89,4 @@ final class DebugCommand extends Command
Task::execTasks();
}
}
}

View File

@ -86,6 +86,18 @@ LOGO;
return $filename;
}
/**
* @param array $argv
* @return array
*/
protected function transArgv(array $argv): array
{
if (!str_contains($argv[1], ':')) {
unset($argv[1]);
}
return array_values($argv);
}
/**
* @return void
*/
@ -98,7 +110,7 @@ LOGO;
->add(new RestoreCommand(), 'm:r') // 模式3
->add(new DebugCommand(), 'm:d') // 模式4
->logo($this->logo)
->handle($this->argv);
->handle($this->transArgv($this->argv));
}
}

View File

@ -112,7 +112,7 @@ class Common
* @param int $length
* @return string
*/
public static function randString(int $length):string
public static function randString(int $length): string
{
// $output='';
// for ($a = 0; $a<$length; $a++) {
@ -126,4 +126,4 @@ class Common
return $key;
}
}
}