1
0
mirror of synced 2025-01-18 14:31:40 +03:00

[2.0] More minor visual cli stuff and help messages

This commit is contained in:
romanb 2009-09-01 16:48:28 +00:00
parent 6e8a511094
commit 374733a9c5
3 changed files with 27 additions and 11 deletions

View File

@ -144,11 +144,13 @@ abstract class AbstractPrinter
* @param string $message Message to be outputted * @param string $message Message to be outputted
* @param mixed $style Optional style to be applied in message * @param mixed $style Optional style to be applied in message
*/ */
public function write($message, $style = 'ERROR') public function write($message, $style = 'NONE')
{ {
$style = is_string($style) ? $this->getStyle($style) : $style; $style = is_string($style) ? $this->getStyle($style) : $style;
fwrite($this->_stream, $this->format($message, $style)); fwrite($this->_stream, $this->format($message, $style));
return $this;
} }
/** /**
@ -157,9 +159,9 @@ abstract class AbstractPrinter
* @param string $message Message to be outputted * @param string $message Message to be outputted
* @param mixed $style Optional style to be applied in message * @param mixed $style Optional style to be applied in message
*/ */
public function writeln($message, $style = 'ERROR') public function writeln($message, $style = 'NONE')
{ {
$this->write($message . PHP_EOL, $style); return $this->write($message . PHP_EOL, $style);
} }
/** /**

View File

@ -16,7 +16,18 @@ class RunSqlTask extends AbstractTask
*/ */
public function extendedHelp() public function extendedHelp()
{ {
$this->getPrinter()->writeln('run-sql extended help.', 'INFO'); $printer = $this->getPrinter();
$printer->write('Task: ')->writeln('run-sql', 'KEYWORD')
->write('Synopsis: ');
$this->_writeSynopsis($printer);
$printer->writeln('Description: Executes arbitrary SQL from a file or directly from the command line.')
->writeln('Options:')
->write('--sql=<SQL>', 'KEYWORD')
->writeln("\tThe SQL to execute.")
->write('--file=<path>', 'KEYWORD')
->writeln("\tThe path to the file with the SQL to execute.");
} }
/** /**
@ -24,10 +35,13 @@ class RunSqlTask extends AbstractTask
*/ */
public function basicHelp() public function basicHelp()
{ {
$this->getPrinter()->write('run-sql', 'KEYWORD'); $this->_writeSynopsis($this->getPrinter());
$this->getPrinter()->writeln( }
' --file=<path> | --sql=<SQL>',
'INFO'); private function _writeSynopsis($printer)
{
$printer->write('run-sql', 'KEYWORD')
->writeln(' --file=<path> | --sql=<SQL>', 'INFO');
} }
/** /**

View File

@ -42,7 +42,7 @@ class SchemaToolTask extends AbstractTask
*/ */
public function extendedHelp() public function extendedHelp()
{ {
$this->getPrinter()->writeln('create-schema extended help.', 'INFO'); $this->basicHelp();
} }
/** /**
@ -136,7 +136,7 @@ class SchemaToolTask extends AbstractTask
if ($isCreate) { if ($isCreate) {
if (isset($args['dump-sql'])) { if (isset($args['dump-sql'])) {
foreach ($tool->getCreateSchemaSql($classes) as $sql) { foreach ($tool->getCreateSchemaSql($classes) as $sql) {
$printer->writeln($sql, 'NONE'); $printer->writeln($sql);
} }
} else { } else {
$printer->writeln('Creating database schema...', 'INFO'); $printer->writeln('Creating database schema...', 'INFO');
@ -146,7 +146,7 @@ class SchemaToolTask extends AbstractTask
} else if ($isDrop) { } else if ($isDrop) {
if (isset($args['dump-sql'])) { if (isset($args['dump-sql'])) {
foreach ($tool->getDropSchemaSql($classes) as $sql) { foreach ($tool->getDropSchemaSql($classes) as $sql) {
$printer->writeln($sql, 'NONE'); $printer->writeln($sql);
} }
} else { } else {
$printer->writeln('Dropping database schema...', 'INFO'); $printer->writeln('Dropping database schema...', 'INFO');