Implement group:show command

This commit is contained in:
Chris 2025-03-14 00:36:13 +01:00
parent 680daec300
commit 8c5e962a55
2 changed files with 17 additions and 5 deletions

4
composer.lock generated
View File

@ -594,7 +594,7 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "../slotdb-client-php", "url": "../slotdb-client-php",
"reference": "f3d6e3e7b3a8daa3111e27407f13ba8c56bf997f" "reference": "bee9457d9da382621e3cc99ffd4b75af443ad27b"
}, },
"require": { "require": {
"psr/http-client": "^1.0" "psr/http-client": "^1.0"
@ -620,7 +620,7 @@
} }
], ],
"description": "SlotDB PHP Client", "description": "SlotDB PHP Client",
"time": "2025-03-13T18:11:29+00:00" "time": "2025-03-13T23:31:13+00:00"
}, },
{ {
"name": "symfony/console", "name": "symfony/console",

View File

@ -22,15 +22,27 @@ class GroupShowCommand extends Command
protected function configure() protected function configure()
{ {
$this->addArgument("group", InputArgument::REQUIRED, "Group to display");
} }
protected function execute(InputInterface $input, OutputInterface $output): int protected function execute(InputInterface $input, OutputInterface $output): int
{ {
$groupId = $input->getArgument("group");
$group = $this->client->queryGroup($groupId);
$groups = $this->client->findGroups(); $len = 2 + max(array_map(mb_strlen(...), array_keys($group)));
var_dump($groups); foreach ($group as $k=>$v) {
$output->writeln(
sprintf(
str_starts_with($k,"_")
? "<fg=green>%{$len}s</>: <fg=gray>%s</>"
: "<fg=green;options=bold>%{$len}s</>: <fg=yellow>%s</>",
$k, json_encode($v)
)
);
}
return self::SUCCESS; return self::SUCCESS;
} }