Skip to content

Commit e26645e

Browse files
author
Gabriel Simmer
committed
Add console output via stderr (prints when piped)
1 parent baa5deb commit e26645e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/DatabaseJanitorCommand.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ protected function configure() {
5252
* Execute Database Janitor functions based on values passed.
5353
*/
5454
protected function execute(InputInterface $input, OutputInterface $output) {
55-
5655
// Set up configuration.
5756
$helper = $this->getHelper('question');
5857
$this->host = $input->getOption('host');
@@ -74,6 +73,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
7473
// "default" until I hear otherwise.
7574
require_once $input->getOption('drupal');
7675
if ($databases['default'] && is_array($databases['default'])) {
76+
fwrite(STDERR, "Loading Drupal configuration. \n");
7777
$db_array = $databases['default']['default'];
7878
$this->host = $db_array['host'];
7979
$this->username = $db_array['username'];
@@ -86,13 +86,15 @@ protected function execute(InputInterface $input, OutputInterface $output) {
8686
);
8787

8888
if (!$input->getOption('trim')) {
89+
fwrite(STDERR, "Dumping database. \n");
8990
$dumpresult = $this->janitor->dump();
9091
if (!$dumpresult) {
9192
$output->writeln("Something went horribly wrong.");
9293
}
9394
}
9495

9596
else {
97+
fwrite(STDERR, "Trimming and scrubbing tables \n");
9698
$trimmed_tables = $this->janitor->trim();
9799
$scrubbed_tables = $this->janitor->scrub();
98100
$ignore_tables = array_merge($trimmed_tables, $scrubbed_tables);
@@ -104,7 +106,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
104106
$this->janitor = new DatabaseJanitor(
105107
$this->database, $this->username, $this->host, $this->password, $this->configuration
106108
);
107-
109+
fwrite(STDERR, "Dumping database.\n");
108110
$dumpresult = $this->janitor->dump();
109111
if (!$dumpresult) {
110112
printf("Something went horribly wrong.");

0 commit comments

Comments
 (0)