diff --git a/components/console/introduction.rst b/components/console/introduction.rst index 81229476e8f..ad772247b62 100644 --- a/components/console/introduction.rst +++ b/components/console/introduction.rst @@ -140,6 +140,9 @@ output. For example:: // white text on a red background $output->writeln('foo'); +The closing tag can be replaced by ````, which revokes all formatting options +established by the last opened tag. + It is possible to define your own styles using the class :class:`Symfony\\Component\\Console\\Formatter\\OutputFormatterStyle`:: @@ -148,23 +151,27 @@ It is possible to define your own styles using the class // ... $style = new OutputFormatterStyle('red', 'yellow', array('bold', 'blink')); $output->getFormatter()->setStyle('fire', $style); - $output->writeln('foo'); + $output->writeln('foo'); Available foreground and background colors are: ``black``, ``red``, ``green``, ``yellow``, ``blue``, ``magenta``, ``cyan`` and ``white``. -And available options are: ``bold``, ``underscore``, ``blink``, ``reverse`` and ``conceal``. +And available options are: ``bold``, ``underscore``, ``blink``, ``reverse`` +(enables the "reverse video" mode where the background and foreground colors +are swapped) and ``conceal`` (sets the foreground color to transparent, making +the typed text invisible - although it can be selected and copied; this option is +commonly used when asking the user to type sensitive information). You can also set these colors and options inside the tagname:: // green text - $output->writeln('foo'); + $output->writeln('foo'); // black text on a cyan background - $output->writeln('foo'); + $output->writeln('foo'); // bold text on a yellow background - $output->writeln('foo'); + $output->writeln('foo'); Verbosity Levels ~~~~~~~~~~~~~~~~ @@ -261,15 +268,15 @@ You can access the ``names`` argument as an array:: $text .= ' '.implode(', ', $names); } -There are 3 argument variants you can use: +There are three argument variants you can use: -=========================== =============================================================================================================== +=========================== =========================================================================================================== Mode Value -=========================== =============================================================================================================== -InputArgument::REQUIRED The argument is required -InputArgument::OPTIONAL The argument is optional and therefore can be omitted -InputArgument::IS_ARRAY The argument can contain an indefinite number of arguments and must be used at the end of the argument list -=========================== =============================================================================================================== +=========================== =========================================================================================================== +``InputArgument::REQUIRED`` The argument is required +``InputArgument::OPTIONAL`` The argument is optional and therefore can be omitted +``InputArgument::IS_ARRAY`` The argument can contain an indefinite number of arguments and must be used at the end of the argument list +=========================== =========================================================================================================== You can combine ``IS_ARRAY`` with ``REQUIRED`` and ``OPTIONAL`` like this:: @@ -342,14 +349,14 @@ will work: There are 4 option variants you can use: -=========================== ===================================================================================== -Option Value -=========================== ===================================================================================== -InputOption::VALUE_IS_ARRAY This option accepts multiple values (e.g. ``--dir=/foo --dir=/bar``) -InputOption::VALUE_NONE Do not accept input for this option (e.g. ``--yell``) -InputOption::VALUE_REQUIRED This value is required (e.g. ``--iterations=5``), the option itself is still optional -InputOption::VALUE_OPTIONAL This option may or may not have a value (e.g. ``--yell`` or ``--yell=loud``) -=========================== ===================================================================================== +=============================== ===================================================================================== +Option Value +=============================== ===================================================================================== +``InputOption::VALUE_IS_ARRAY`` This option accepts multiple values (e.g. ``--dir=/foo --dir=/bar``) +``InputOption::VALUE_NONE`` Do not accept input for this option (e.g. ``--yell``) +``InputOption::VALUE_REQUIRED`` This value is required (e.g. ``--iterations=5``), the option itself is still optional +``InputOption::VALUE_OPTIONAL`` This option may or may not have a value (e.g. ``--yell`` or ``--yell=loud``) +=============================== ===================================================================================== You can combine ``VALUE_IS_ARRAY`` with ``VALUE_REQUIRED`` or ``VALUE_OPTIONAL`` like this: