Plugin fixes
* Added vertical rendering to com.noccy.pdo.shell * Added missing Log classes for com.noccy.apiclient
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
|
||||
namespace SparkPlug\Com\Noccy\Pdo\Shell\Shell;
|
||||
|
||||
use Attribute;
|
||||
use SparkPlug\Com\Noccy\Pdo\PdoResource;
|
||||
use Spark\Commands\Command;
|
||||
use Spark\SparkApplication;
|
||||
@ -28,6 +29,7 @@ class PdoShell {
|
||||
|
||||
private ?array $lastQuery = null;
|
||||
|
||||
#[EnumSetting('output', [ 'table', 'vertical', 'dump' ])]
|
||||
private array $defaultOptions = [
|
||||
'output' => 'table',
|
||||
'table.maxwidth' => 40,
|
||||
@ -338,5 +340,31 @@ class PdoShell {
|
||||
$table->render();
|
||||
}
|
||||
|
||||
private function dumpQueryVertical(array $res)
|
||||
{
|
||||
if (count($res) == 0) return;
|
||||
$names = array_keys(reset($res));
|
||||
$nameWidth = max(array_map("strlen", $names)) + 4;
|
||||
|
||||
foreach ($res as $row) {
|
||||
foreach ($row as $k=>$v) {
|
||||
$this->output->writeln(
|
||||
sprintf("<info>%{$nameWidth}s</>: %s",$k, $v)
|
||||
);
|
||||
}
|
||||
if ($row != end($res)) {
|
||||
$this->output->writeln(str_repeat("-", $nameWidth));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#[Attribute(Attribute::TARGET_PROPERTY)]
|
||||
class EnumSetting
|
||||
{
|
||||
public function __construct(string $property, array $valid)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user