4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Console\Descriptor;
14 use Symfony\Component\Console\Application;
15 use Symfony\Component\Console\Command\Command;
16 use Symfony\Component\Console\Input\InputArgument;
17 use Symfony\Component\Console\Input\InputDefinition;
18 use Symfony\Component\Console\Input\InputOption;
19 use Symfony\Component\Console\Output\OutputInterface;
20 use Symfony\Component\Console\Exception\InvalidArgumentException;
23 * @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
27 abstract class Descriptor implements DescriptorInterface
30 * @var OutputInterface
37 public function describe(OutputInterface $output, $object, array $options = array())
39 $this->output = $output;
42 case $object instanceof InputArgument:
43 $this->describeInputArgument($object, $options);
45 case $object instanceof InputOption:
46 $this->describeInputOption($object, $options);
48 case $object instanceof InputDefinition:
49 $this->describeInputDefinition($object, $options);
51 case $object instanceof Command:
52 $this->describeCommand($object, $options);
54 case $object instanceof Application:
55 $this->describeApplication($object, $options);
58 throw new InvalidArgumentException(sprintf('Object of type "%s" is not describable.', get_class($object)));
63 * Writes content to output.
65 * @param string $content
66 * @param bool $decorated
68 protected function write($content, $decorated = false)
70 $this->output->write($content, false, $decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW);
74 * Describes an InputArgument instance.
76 * @param InputArgument $argument
77 * @param array $options
79 * @return string|mixed
81 abstract protected function describeInputArgument(InputArgument $argument, array $options = array());
84 * Describes an InputOption instance.
86 * @param InputOption $option
87 * @param array $options
89 * @return string|mixed
91 abstract protected function describeInputOption(InputOption $option, array $options = array());
94 * Describes an InputDefinition instance.
96 * @param InputDefinition $definition
97 * @param array $options
99 * @return string|mixed
101 abstract protected function describeInputDefinition(InputDefinition $definition, array $options = array());
104 * Describes a Command instance.
106 * @param Command $command
107 * @param array $options
109 * @return string|mixed
111 abstract protected function describeCommand(Command $command, array $options = array());
114 * Describes an Application instance.
116 * @param Application $application
117 * @param array $options
119 * @return string|mixed
121 abstract protected function describeApplication(Application $application, array $options = array());