diff --git a/lib/Command/Daemon/ListDaemons.php b/lib/Command/Daemon/ListDaemons.php
index 1c7b8bee..bb1a3799 100644
--- a/lib/Command/Daemon/ListDaemons.php
+++ b/lib/Command/Daemon/ListDaemons.php
@@ -9,16 +9,15 @@
namespace OCA\AppAPI\Command\Daemon;
+use OC\Core\Command\Base;
use OCA\AppAPI\AppInfo\Application;
use OCA\AppAPI\Service\DaemonConfigService;
-
use OCP\IAppConfig;
-use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
-class ListDaemons extends Command {
+class ListDaemons extends Base {
public function __construct(
private readonly DaemonConfigService $daemonConfigService,
@@ -28,6 +27,7 @@ public function __construct(
}
protected function configure(): void {
+ parent::configure();
$this->setName('app_api:daemon:list');
$this->setDescription('List registered daemons');
}
@@ -41,27 +41,50 @@ 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 = [];
+ if (in_array($input->getOption('output'), [self::OUTPUT_FORMAT_JSON, self::OUTPUT_FORMAT_JSON_PRETTY], true)) {
+ $allDaemonInfo = [];
+ foreach ($daemonConfigs as $daemon) {
+ $deployConfig = $daemon->getDeployConfig();
- 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)',
- ];
- }
+ if (isset($deployConfig['haproxy_password'])) {
+ $deployConfig['haproxy_password'] = '***';
+ }
+
+ $allDaemonInfo[] = [
+ 'name' => $daemon->getName(),
+ 'display_name' => $daemon->getDisplayName(),
+ 'deploy_id' => $daemon->getAcceptsDeployId(),
+ 'protocol' => $daemon->getProtocol(),
+ 'host' => $daemon->getHost(),
+ 'deploy_config' => $deployConfig,
+ ];
+ }
+ $this->writeArrayInOutputFormat($input, $output, $allDaemonInfo);
+ } else {
+ $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']);
- $table->setRows($rows);
- $table->render();
+ $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);
+ $output->writeln('Registered ExApp daemon configs:');
+ $table->render();
+ }
return 0;
}
diff --git a/psalm.xml b/psalm.xml
index 98283151..7f6c1930 100644
--- a/psalm.xml
+++ b/psalm.xml
@@ -35,6 +35,7 @@
+