truncate long values on default

This commit is contained in:
Robin Appelman 2015-11-23 12:29:20 +01:00
parent 0795f7d71b
commit ff72eac927
1 changed files with 17 additions and 1 deletions

View File

@ -77,6 +77,11 @@ class ListCommand extends Base {
null,
InputOption::VALUE_NONE,
'show passwords and secrets'
)->addOption(
'full',
null,
InputOption::VALUE_NONE,
'dont truncate long values in table output'
);
parent::configure();
}
@ -154,16 +159,27 @@ class ListCommand extends Base {
$output->writeln(json_encode(array_values($pairs), JSON_PRETTY_PRINT));
}
} else {
$full = $input->getOption('full');
$defaultMountOptions = [
'encrypt' => true,
'previews' => true,
'filesystem_check_changes' => 1
];
$rows = array_map(function (StorageConfig $config) use ($userId, $defaultMountOptions) {
$rows = array_map(function (StorageConfig $config) use ($userId, $defaultMountOptions, $full) {
$storageConfig = $config->getBackendOptions();
$keys = array_keys($storageConfig);
$values = array_values($storageConfig);
if (!$full) {
$values = array_map(function ($value) {
if (is_string($value) && strlen($value) > 32) {
return substr($value, 0, 6) . '...' . substr($value, -6, 6);
} else {
return $value;
}
}, $values);
}
$configStrings = array_map(function ($key, $value) {
return $key . ': ' . json_encode($value);
}, $keys, $values);