mirror of
https://github.com/shlinkio/shlink.git
synced 2025-04-06 00:35:21 +03:00
Improved output on api-key:list command
This commit is contained in:
parent
31594d47b3
commit
e3cbac38ce
1 changed files with 24 additions and 3 deletions
|
@ -73,12 +73,15 @@ class ListKeysCommand extends Command
|
||||||
$key = $row->getKey();
|
$key = $row->getKey();
|
||||||
$expiration = $row->getExpirationDate();
|
$expiration = $row->getExpirationDate();
|
||||||
$rowData = [];
|
$rowData = [];
|
||||||
|
$formatMethod = ! $row->isEnabled()
|
||||||
|
? 'getErrorString'
|
||||||
|
: ($row->isExpired() ? 'getWarningString' : 'getSuccessString');
|
||||||
|
|
||||||
if ($enabledOnly) {
|
if ($enabledOnly) {
|
||||||
$rowData[] = $key;
|
$rowData[] = $this->{$formatMethod}($key);
|
||||||
} else {
|
} else {
|
||||||
$rowData[] = $row->isEnabled() ? $this->getSuccessString($key) : $this->getErrorString($key);
|
$rowData[] = $this->{$formatMethod}($key);
|
||||||
$rowData[] = $row->isEnabled() ? $this->getSuccessString('+++') : $this->getErrorString('---');
|
$rowData[] = $this->{$formatMethod}($this->getEnabledSymbol($row));
|
||||||
}
|
}
|
||||||
|
|
||||||
$rowData[] = isset($expiration) ? $expiration->format(\DateTime::ISO8601) : '-';
|
$rowData[] = isset($expiration) ? $expiration->format(\DateTime::ISO8601) : '-';
|
||||||
|
@ -105,4 +108,22 @@ class ListKeysCommand extends Command
|
||||||
{
|
{
|
||||||
return sprintf('<info>%s</info>', $string);
|
return sprintf('<info>%s</info>', $string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $string
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getWarningString($string)
|
||||||
|
{
|
||||||
|
return sprintf('<comment>%s</comment>', $string);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ApiKey $apiKey
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getEnabledSymbol(ApiKey $apiKey)
|
||||||
|
{
|
||||||
|
return ! $apiKey->isEnabled() || $apiKey->isExpired() ? '---' : '+++';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue