Skip to content

Commit 58fba1b

Browse files
authored
Merge pull request #10 from congpeijun/master
Add color for output info.
2 parents d07f21a + ddf0f65 commit 58fba1b

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/Command/SchemaLoadCommand.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ public function execute(InputInterface $input, OutputInterface $output)
5757
$url = $input->getArgument('url');
5858
$filename = $input->getArgument('filename');
5959
$apply = $input->getOption('apply');
60-
61-
60+
61+
6262
$scheme = parse_url($url, PHP_URL_SCHEME);
6363
$user = parse_url($url, PHP_URL_USER);
6464
$pass = parse_url($url, PHP_URL_PASS);
@@ -80,14 +80,14 @@ public function execute(InputInterface $input, OutputInterface $output)
8080
} catch (\Exception $e) {
8181
throw new RuntimeException("Can't connect to server with provided address and credentials");
8282
}
83-
83+
8484
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
8585
$stmt = $pdo->query("SELECT COUNT(*) FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '" . $dbname . "'");
8686
if (!$stmt->fetchColumn()) {
87-
$output->writeln("Creating database");
87+
$output->writeln("<info>Creating database</info>");
8888
$stmt = $pdo->query("CREATE DATABASE " . $dbname . "");
8989
} else {
90-
$output->writeln("Database exists...");
90+
$output->writeln("<error>Database exists...</error>");
9191
}
9292

9393
$loader = LoaderFactory::getInstance()->getLoader($filename);
@@ -99,12 +99,12 @@ public function execute(InputInterface $input, OutputInterface $output)
9999
$connectionParams = array(
100100
'url' => $dbmanager->getUrlByDatabaseName($url)
101101
);
102-
103-
102+
103+
104104
$connection = DriverManager::getConnection($connectionParams, $config);
105105

106106
$output->writeln(sprintf(
107-
'Loading file `%s` into database `%s`',
107+
'<info>Loading file <comment>`%s`</comment> into database <comment>`%s`</comment></info>',
108108
$filename,
109109
$url
110110
));
@@ -120,22 +120,22 @@ public function execute(InputInterface $input, OutputInterface $output)
120120
$queries = $schemaDiff->toSaveSql($platform);
121121

122122
if (!count($queries)) {
123-
$output->writeln("No schema changes required");
123+
$output->writeln("<info>No schema changes required</info>");
124124
return;
125125
}
126126

127127
if ($apply) {
128-
$output->writeln("APPLYING...");
128+
$output->writeln("<info>APPLYING...</info>");
129129
foreach ($queries as $query) {
130130
$output->writeln(sprintf(
131-
'Running: %s',
131+
'<info>Running: <comment>%s</comment></info>',
132132
$query
133133
));
134134

135135
$stmt = $connection->query($query);
136136
}
137137
} else {
138-
$output->writeln("CHANGES: The following SQL statements need to be executed to synchronise the schema (use --apply)");
138+
$output->writeln("<info>CHANGES: The following SQL statements need to be executed to synchronise the schema (use <comment>--apply</comment>)</info>");
139139

140140
foreach ($queries as $query) {
141141
$output->writeln($query);

0 commit comments

Comments
 (0)