Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 84 lines (71 sloc) 2.258 kb
68c191cd » fabpot
2010-08-20 renamed Symfony\Components to Symfony\Component
1 <?php
2
4a83d996 » blue-eyes
2011-01-15 normalized license messages in PHP files
3 /*
4 * This file is part of the Symfony package.
5 *
b9338056 » fabpot
2011-03-06 replaced symfony-project.org by symfony.com
6 * (c) Fabien Potencier <fabien@symfony.com>
4a83d996 » blue-eyes
2011-01-15 normalized license messages in PHP files
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
68c191cd » fabpot
2010-08-20 renamed Symfony\Components to Symfony\Component
12 namespace Symfony\Component\Console\Command;
13
14 use Symfony\Component\Console\Input\InputArgument;
15 use Symfony\Component\Console\Input\InputOption;
16 use Symfony\Component\Console\Input\InputInterface;
17 use Symfony\Component\Console\Output\OutputInterface;
18 use Symfony\Component\Console\Output\Output;
19 use Symfony\Component\Console\Command\Command;
20
21 /**
22 * HelpCommand displays the help for a given command.
23 *
b9338056 » fabpot
2011-03-06 replaced symfony-project.org by symfony.com
24 * @author Fabien Potencier <fabien@symfony.com>
68c191cd » fabpot
2010-08-20 renamed Symfony\Components to Symfony\Component
25 */
26 class HelpCommand extends Command
27 {
67dbf5e1 » fabpot
2011-03-11 moved most protected to private in the Console component
28 private $command;
68c191cd » fabpot
2010-08-20 renamed Symfony\Components to Symfony\Component
29
30 /**
1fc85eea » merk
2011-02-06 PHPDoc for Console
31 * {@inheritdoc}
68c191cd » fabpot
2010-08-20 renamed Symfony\Components to Symfony\Component
32 */
33 protected function configure()
34 {
44cce6b1 » fabpot
2012-01-06 [Console] added a missing method (closes #3043)
35 $this->ignoreValidationErrors();
68c191cd » fabpot
2010-08-20 renamed Symfony\Components to Symfony\Component
36
37 $this
f48469a3 » Tobion
2012-02-12 replaced command names with supported placeholders in help texts
38 ->setName('help')
68c191cd » fabpot
2010-08-20 renamed Symfony\Components to Symfony\Component
39 ->setDefinition(array(
40 new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'),
44cf1791 » weaverryan
2010-11-27 [Command] Changing the InputOption::PARAMETER_* constants to InputOpt…
41 new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'),
68c191cd » fabpot
2010-08-20 renamed Symfony\Components to Symfony\Component
42 ))
43 ->setDescription('Displays help for a command')
44 ->setHelp(<<<EOF
f48469a3 » Tobion
2012-02-12 replaced command names with supported placeholders in help texts
45 The <info>%command.name%</info> command displays help for a given command:
68c191cd » fabpot
2010-08-20 renamed Symfony\Components to Symfony\Component
46
f48469a3 » Tobion
2012-02-12 replaced command names with supported placeholders in help texts
47 <info>php %command.full_name% list</info>
68c191cd » fabpot
2010-08-20 renamed Symfony\Components to Symfony\Component
48
49 You can also output the help as XML by using the <comment>--xml</comment> option:
50
f48469a3 » Tobion
2012-02-12 replaced command names with supported placeholders in help texts
51 <info>php %command.full_name% --xml list</info>
68c191cd » fabpot
2010-08-20 renamed Symfony\Components to Symfony\Component
52 EOF
f48469a3 » Tobion
2012-02-12 replaced command names with supported placeholders in help texts
53 )
54 ;
68c191cd » fabpot
2010-08-20 renamed Symfony\Components to Symfony\Component
55 }
56
1fc85eea » merk
2011-02-06 PHPDoc for Console
57 /**
58 * Sets the command
59 *
60 * @param Command $command The command to set
61 */
68c191cd » fabpot
2010-08-20 renamed Symfony\Components to Symfony\Component
62 public function setCommand(Command $command)
63 {
64 $this->command = $command;
65 }
66
67 /**
1fc85eea » merk
2011-02-06 PHPDoc for Console
68 * {@inheritdoc}
68c191cd » fabpot
2010-08-20 renamed Symfony\Components to Symfony\Component
69 */
70 protected function execute(InputInterface $input, OutputInterface $output)
71 {
72 if (null === $this->command) {
eda5644d » Gunther Konig
2012-09-20 use ->find instead of ->get in the help command to allow command alia…
73 $this->command = $this->getApplication()->find($input->getArgument('command_name'));
68c191cd » fabpot
2010-08-20 renamed Symfony\Components to Symfony\Component
74 }
75
76 if ($input->getOption('xml')) {
44124245 » fabpot
2011-03-29 [Console] moved Output constants to OutputInterface
77 $output->writeln($this->command->asXml(), OutputInterface::OUTPUT_RAW);
68c191cd » fabpot
2010-08-20 renamed Symfony\Components to Symfony\Component
78 } else {
79 $output->writeln($this->command->asText());
80 }
d43963be » fabpot
2012-03-02 [Console] fixed help command when used from the shell (closes #3480)
81
82 $this->command = null;
68c191cd » fabpot
2010-08-20 renamed Symfony\Components to Symfony\Component
83 }
84 }
Something went wrong with that request. Please try again.