Skip to content

Commit

Permalink
add more information on inspect:database
Browse files Browse the repository at this point in the history
  • Loading branch information
chanmix51 committed Mar 13, 2017
1 parent 80b39e5 commit 9c698c8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
28 changes: 18 additions & 10 deletions sources/lib/Command/InspectDatabase.php
Expand Up @@ -50,12 +50,11 @@ public function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
parent::execute($input, $output);
$info = $this
->getSession()
->getInspector()
->getSchemas()
;
$this->formatOutput($output, $info);
$info = $this->getSession()->getInspector('schema')->getUserSchemas();
$version = $this->getSession()->getInspector('database')->getVersion();
$size = $this->getSession()->getInspector('database')->getSizePretty();
$name = $this->getSession()->getInspector('database')->getName();
$this->formatOutput($output, $info, $version, $size, $name);
}

/**
Expand All @@ -68,23 +67,32 @@ protected function execute(InputInterface $input, OutputInterface $output)
* @param ResultIterator $iterator
* @return null
*/
protected function formatOutput(OutputInterface $output, ResultIterator $iterator)
protected function formatOutput(OutputInterface $output, ResultIterator $iterator, $version, $size, $name)
{
$output->writeln(
sprintf(
"Found <info>%d</info> schemas in database.",
$iterator->count()
"PostgreSQL v.%s",
$version
)
);
$output->writeln(
sprintf(
"Found <info>%d</info> schemas in database \"%s\" (%s).",
$iterator->count(),
$name,
$size
)
);
$table = (new Table($output))
->setHeaders(['name', 'oid ', 'relations', 'comment'])
->setHeaders(['name', 'oid ', 'relations', 'owner', 'comment'])
;

foreach ($iterator as $schema_info) {
$table->addRow([
sprintf("<fg=yellow>%s</fg=yellow>", $schema_info['name']),
$schema_info['oid'],
$schema_info['relations'],
$schema_info['owner'],
wordwrap($schema_info['comment'])
]);
}
Expand Down
5 changes: 2 additions & 3 deletions sources/tests/Unit/Command/InspectDatabase.php
Expand Up @@ -41,9 +41,8 @@ public function testExecute()
);
$this
->string($tester->getDisplay())
->contains("| pomm_test")
->contains("This is a test schema.")
->contains(" 4 ")
->matches('#|\s+pomm_test\s+|\s+[0-9]+\s+|\s+4\s+|\s+"*[\w-]+"*\s+|\s+This is a test schema.\s+|#')
->matches('#Found [0-9]+ schemas in database "\w+"#')
;
}
}

0 comments on commit 9c698c8

Please sign in to comment.