Skip to content

Commit

Permalink
[fix] Command argv parse error
Browse files Browse the repository at this point in the history
  • Loading branch information
lkeme committed Sep 10, 2022
1 parent a3b52e3 commit 6fd6113
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/Console/Command/DebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ public function execute(): void
{
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'];
Expand All @@ -76,7 +80,7 @@ public function execute(): void
//
$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);
Expand All @@ -85,5 +89,4 @@ public function execute(): void
Task::execTasks();
}


}
}
14 changes: 13 additions & 1 deletion src/Console/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@ public static function parse(array $argv, string $default = 'user'): string
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
*/
Expand All @@ -98,7 +110,7 @@ public function register(): void
->add(new RestoreCommand(), 'm:r') // 模式3
->add(new DebugCommand(), 'm:d') // 模式4
->logo($this->logo)
->handle($this->argv);
->handle($this->transArgv($this->argv));
}

}
4 changes: 2 additions & 2 deletions src/Util/Common/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public static function customCreateUUID(string $data): string
* @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++) {
Expand All @@ -126,4 +126,4 @@ public static function randString(int $length):string
return $key;
}

}
}

0 comments on commit 6fd6113

Please sign in to comment.