Apply copilot's suggestion

This commit is contained in:
crazywhalecc
2025-12-11 14:43:42 +08:00
parent 6d292b4c54
commit e3f9894331

View File

@@ -15,7 +15,7 @@ class EnvCommand extends BaseCommand
{ {
public function configure(): void public function configure(): void
{ {
$this->addArgument('env', InputArgument::REQUIRED, 'The environment variable to show, if not set, all will be shown'); $this->addArgument('env', InputArgument::OPTIONAL, 'The environment variable to show, if not set, all will be shown');
} }
public function initialize(InputInterface $input, OutputInterface $output): void public function initialize(InputInterface $input, OutputInterface $output): void
@@ -31,6 +31,12 @@ class EnvCommand extends BaseCommand
$this->output->writeln("<error>Environment variable '{$env}' is not set.</error>"); $this->output->writeln("<error>Environment variable '{$env}' is not set.</error>");
return static::FAILURE; return static::FAILURE;
} }
if (is_array($val)) {
foreach ($val as $k => $v) {
$this->output->writeln("<info>{$k}={$v}</info>");
}
return static::SUCCESS;
}
$this->output->writeln("<info>{$val}</info>"); $this->output->writeln("<info>{$val}</info>");
return static::SUCCESS; return static::SUCCESS;
} }