From: Lucas Azevedo Date: Fri, 25 Aug 2023 14:13:34 +0000 (-0300) Subject: Use table output for list command X-Git-Tag: v28.0.0beta1~459^2~2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9c66bf6dc3ca29ac52f6fd83ff0d05edafb917b3;p=nextcloud-server.git Use table output for list command Signed-off-by: Lucas Azevedo --- diff --git a/core/Command/User/AuthTokens/ListCommand.php b/core/Command/User/AuthTokens/ListCommand.php index 6739e8b4648..97e94f29f92 100644 --- a/core/Command/User/AuthTokens/ListCommand.php +++ b/core/Command/User/AuthTokens/ListCommand.php @@ -61,18 +61,24 @@ class ListCommand extends Base { $tokens = $this->tokenProvider->getTokenByUser($user->getUID()); - $data = array_map(function (IToken $token): mixed { - $filtered = [ + $tokens = array_map(function (IToken $token) use ($input): mixed { + $sensitive = [ 'password', 'password_hash', 'token', 'public_key', 'private_key', ]; - return array_diff_key($token->jsonSerialize(), array_flip($filtered)); + $data = array_diff_key($token->jsonSerialize(), array_flip($sensitive)); + + if ($input->getOption('output') === self::OUTPUT_FORMAT_PLAIN) { + $data['scope'] = implode(', ', array_keys(array_filter($data['scope']))); + } + + return $data; }, $tokens); - $this->writeArrayInOutputFormat($input, $output, $data); + $this->writeTableInOutputFormat($input, $output, $tokens); return 0; }