diff --git a/lib/Command/Daemon/ListDaemons.php b/lib/Command/Daemon/ListDaemons.php index 1c7b8bee..fdaa526d 100644 --- a/lib/Command/Daemon/ListDaemons.php +++ b/lib/Command/Daemon/ListDaemons.php @@ -16,6 +16,7 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class ListDaemons extends Command { @@ -30,6 +31,7 @@ public function __construct( protected function configure(): void { $this->setName('app_api:daemon:list'); $this->setDescription('List registered daemons'); + $this->addOption('show-deploy-config', null, InputOption::VALUE_NONE, 'Show full deploy configuration'); } protected function execute(InputInterface $input, OutputInterface $output): int { @@ -42,26 +44,52 @@ protected function execute(InputInterface $input, OutputInterface $output): int $defaultDaemonName = $this->appConfig->getValueString(Application::APP_ID, 'default_daemon_config', lazy: true); $output->writeln('Registered ExApp daemon configs:'); - $table = new Table($output); - $table->setHeaders(['Def', 'Name', 'Display name', 'Deploy ID', 'Protocol', 'Host', 'NC Url', 'Is HaRP', 'HaRP FRP Address', 'HaRP Docker Socket Port']); - $rows = []; - - foreach ($daemonConfigs as $daemon) { - $rows[] = [ - $daemon->getName() === $defaultDaemonName ? '*' : '', - $daemon->getName(), $daemon->getDisplayName(), - $daemon->getAcceptsDeployId(), - $daemon->getProtocol(), - $daemon->getHost(), - $daemon->getDeployConfig()['nextcloud_url'], - isset($daemon->getDeployConfig()['harp']) ? 'yes' : 'no', - $daemon->getDeployConfig()['harp']['frp_address'] ?? '(none)', - $daemon->getDeployConfig()['harp']['docker_socket_port'] ?? '(none)', - ]; - } - $table->setRows($rows); - $table->render(); + if ($input->getOption('show-deploy-config')) { + foreach ($daemonConfigs as $daemon) { + $deployConfig = $daemon->getDeployConfig(); + + if (isset($deployConfig['haproxy_password'])) { + $deployConfig['haproxy_password'] = '***'; + } + + $daemonInfo = [ + 'name' => $daemon->getName(), + 'display_name' => $daemon->getDisplayName(), + 'deploy_id' => $daemon->getAcceptsDeployId(), + 'protocol' => $daemon->getProtocol(), + 'host' => $daemon->getHost(), + 'deploy_config' => $deployConfig, + ]; + + $output->writeln(json_encode($daemonInfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); + $output->writeln(''); + } + } else { + $table = new Table($output); + $headers = ['Def', 'Name', 'Display name', 'Deploy ID', 'Protocol', 'Host', 'NC Url', 'Is HaRP', 'HaRP FRP Address', 'HaRP Docker Socket Port']; + $table->setHeaders($headers); + + $rows = []; + foreach ($daemonConfigs as $daemon) { + $deployConfig = $daemon->getDeployConfig(); + $rows[] = [ + $daemon->getName() === $defaultDaemonName ? '*' : '', + $daemon->getName(), + $daemon->getDisplayName(), + $daemon->getAcceptsDeployId(), + $daemon->getProtocol(), + $daemon->getHost(), + $deployConfig['nextcloud_url'], + isset($deployConfig['harp']) ? 'yes' : 'no', + $deployConfig['harp']['frp_address'] ?? '(none)', + $deployConfig['harp']['docker_socket_port'] ?? '(none)', + ]; + } + + $table->setRows($rows); + $table->render(); + } return 0; }