From 203b46dea233b526ced24a21e94b2c16691f1299 Mon Sep 17 00:00:00 2001 From: guilhermeblanco Date: Fri, 4 Sep 2009 17:24:48 +0000 Subject: [PATCH] [2.0] Changed stylish of CLI tasks. Added CLI documentation for SchemaTool task --- .../Tools/Cli/Printers/AnsiColorPrinter.php | 4 +- .../ORM/Tools/Cli/Tasks/RunSqlTask.php | 11 ++++-- .../ORM/Tools/Cli/Tasks/SchemaToolTask.php | 38 ++++++++++++++++--- 3 files changed, 43 insertions(+), 10 deletions(-) diff --git a/lib/Doctrine/ORM/Tools/Cli/Printers/AnsiColorPrinter.php b/lib/Doctrine/ORM/Tools/Cli/Printers/AnsiColorPrinter.php index e80371e91..77df0046b 100644 --- a/lib/Doctrine/ORM/Tools/Cli/Printers/AnsiColorPrinter.php +++ b/lib/Doctrine/ORM/Tools/Cli/Printers/AnsiColorPrinter.php @@ -42,12 +42,14 @@ class AnsiColorPrinter extends AbstractPrinter protected function _initStyles() { $this->addStyles(array( + 'HEADER' => new Style('DEFAULT', 'DEFAULT', array('BOLD' => true)), 'ERROR' => new Style('WHITE', 'RED', array('BOLD' => true)), 'WARNING' => new Style('DEFAULT', 'YELLOW'), 'KEYWORD' => new Style('BLUE', 'DEFAULT', array('BOLD' => true)), + 'REQ_ARG' => new Style('MAGENTA', 'DEFAULT', array('BOLD' => true)), + 'OPT_ARG' => new Style('CYAN', 'DEFAULT', array('BOLD' => true)), 'INFO' => new Style('GREEN', 'DEFAULT', array('BOLD' => true)), 'COMMENT' => new Style('DEFAULT', 'MAGENTA'), - 'HEADER' => new Style('DEFAULT', 'DEFAULT', array('BOLD' => true)), 'NONE' => new Style(), )); } diff --git a/lib/Doctrine/ORM/Tools/Cli/Tasks/RunSqlTask.php b/lib/Doctrine/ORM/Tools/Cli/Tasks/RunSqlTask.php index 623b44b6b..c1cef2aa0 100644 --- a/lib/Doctrine/ORM/Tools/Cli/Tasks/RunSqlTask.php +++ b/lib/Doctrine/ORM/Tools/Cli/Tasks/RunSqlTask.php @@ -24,10 +24,13 @@ class RunSqlTask extends AbstractTask $printer->writeln('Description: Executes arbitrary SQL from a file or directly from the command line.') ->writeln('Options:') - ->write('--sql=', 'KEYWORD') + ->write('--sql=', 'REQ_ARG') ->writeln("\tThe SQL to execute.") - ->write('--file=', 'KEYWORD') - ->writeln("\tThe path to the file with the SQL to execute."); + ->writeln("\t\tIf defined, --file can not be requested on same task") + ->write(PHP_EOL) + ->write('--file=', 'REQ_ARG') + ->writeln("\tThe path to the file with the SQL to execute.") + ->writeln("\t\tIf defined, --sql can not be requested on same task"); } /** @@ -41,7 +44,7 @@ class RunSqlTask extends AbstractTask private function _writeSynopsis($printer) { $printer->write('run-sql', 'KEYWORD') - ->writeln(' (--file= | --sql=)', 'INFO'); + ->writeln(' (--file= | --sql=)', 'REQ_ARG'); } /** diff --git a/lib/Doctrine/ORM/Tools/Cli/Tasks/SchemaToolTask.php b/lib/Doctrine/ORM/Tools/Cli/Tasks/SchemaToolTask.php index 976aee395..a02ad69e2 100644 --- a/lib/Doctrine/ORM/Tools/Cli/Tasks/SchemaToolTask.php +++ b/lib/Doctrine/ORM/Tools/Cli/Tasks/SchemaToolTask.php @@ -42,7 +42,31 @@ class SchemaToolTask extends AbstractTask */ public function extendedHelp() { - $this->basicHelp(); + $printer = $this->getPrinter(); + + $printer->write('Task: ')->writeln('schema-tool', 'KEYWORD') + ->write('Synopsis: '); + $this->_writeSynopsis($printer); + + $printer->writeln('Description: Processes the schema and either apply it directly on EntityManager or generate the SQL output.') + ->writeln('Options:') + ->write('--create', 'REQ_ARG') + ->writeln("\t\tCreates the schema in EntityManager (create tables on Database)") + ->writeln("\t\t\tIf defined, --drop and --update can not be requested on same task") + ->write(PHP_EOL) + ->write('--drop', 'REQ_ARG') + ->writeln("\t\t\tDrops the schema of EntityManager (drop tables on Database)") + ->writeln("\t\t\tIf defined, --create and --update can not be requested on same task") + ->write(PHP_EOL) + ->write('--update', 'REQ_ARG') + ->writeln("\t\tUpdates the schema in EntityManager (update tables on Database)") + ->writeln("\t\t\tIf defined, --create and --drop can not be requested on same task") + ->write(PHP_EOL) + ->write('--dump-sql', 'OPT_ARG') + ->writeln("\t\tInstead of try to apply generated SQLs into EntityManager, output them.") + ->write(PHP_EOL) + ->write('--classdir=', 'OPT_ARG') + ->writeln("\tOptional class directory to fetch for Entities."); } /** @@ -50,10 +74,14 @@ class SchemaToolTask extends AbstractTask */ public function basicHelp() { - $this->getPrinter()->write('schema-tool', 'KEYWORD'); - $this->getPrinter()->writeln( - ' (--create | --drop | --update) [--dump-sql] [--classdir=]', - 'INFO'); + $this->_writeSynopsis($this->getPrinter()); + } + + private function _writeSynopsis($printer) + { + $printer->write('schema-tool', 'KEYWORD') + ->write(' (--create | --drop | --update)', 'REQ_ARG') + ->writeln(' [--dump-sql] [--classdir=]', 'OPT_ARG'); } /**