Add --json to polls list and polls show
CI / Deploy / PHP 8.5 (push) Successful in 1m37s
CI / Deploy / PHP 8.4 (push) Successful in 1m39s
CI / Deploy / test (push) Successful in 2s
CI / Deploy / deploy (push) Skipped

Machine-readable output for scripts; never contains the admin token
unless --link is given.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Sonnet 5.5 committed 2026-11-16 13:59:38 +01:00
1 parent 664088e139
commit 3d6ade668f
6 files changed
+115 -2

No files matched your search

+19
View File
@@ -34,6 +34,10 @@ class PollsShowCommand extends PollsCommand
'help' => __('ID oder Beitrittscode der Umfrage.'),
'required' => true,
])
->addOption('json', [
'help' => __('Ausgabe als JSON statt als Text (für Skripte).'),
'boolean' => true,
])
->addOption('link', [
'help' => __('Auch den Admin-Link ausgeben (enthält das geheime Token!).'),
'boolean' => true,
@@ -55,6 +59,21 @@ class PollsShowCommand extends PollsCommand
}
$slides = $this->fetchTable('Slides')->find()->where(['poll_id' => $poll->id])->count();
if ($args->getOption('json')) {
$data = $this->pollData($poll) + ['slides' => $slides, 'adminUrl' => null];
if ($args->getOption('link')) {
$data['adminUrl'] = $this->adminLink($poll);
if ($data['adminUrl'] === null) {
$io->err(__('Der Admin-Link lässt sich nicht entschlüsseln (SECURITY_SALT geändert?).'));
return static::CODE_ERROR;
}
}
$this->printJson($io, $data);
return static::CODE_SUCCESS;
}
$io->out([
__('ID: {0}', $poll->id),
__('Titel: {0}', $poll->title),