3 namespace Friendica\Core;
\r
6 * Description of Console
\r
8 * @author Hypolite Petovan <mrpetovan@gmail.com>
\r
10 class Console extends \Asika\SimpleConsole\Console
\r
12 // Disables the default help handling
\r
13 protected $helpOptions = [];
\r
14 protected $customHelpOptions = ['h', 'help', '?'];
\r
16 protected function getHelp()
\r
21 Usage: bin/console [--version] [-h|--help|-?] <command> [<args>] [-v]
\r
24 config Edit site config
\r
25 createdoxygen Generate Doxygen headers
\r
26 docbloxerrorchecker Checks the file tree for DocBlox errors
\r
27 globalcommunityblock Silence remote profile from global community page
\r
28 help Show help about a command, e.g (bin/console help config)
\r
31 -h|--help|-? Show help information
\r
32 -v Show more debug information.
\r
37 protected function doExecute()
\r
39 if ($this->getOption('v')) {
\r
40 $this->out('Executable: ' . $this->executable);
\r
41 $this->out('Arguments: ' . var_export($this->args, true));
\r
42 $this->out('Options: ' . var_export($this->options, true));
\r
49 if ($this->getOption('version')) {
\r
50 $this->out('Friendica Console version ' . FRIENDICA_VERSION);
\r
53 } elseif ((count($this->options) === 0 || $this->getOption($this->customHelpOptions) === true || $this->getOption($this->customHelpOptions) === 1) && count($this->args) === 0
\r
56 } elseif (count($this->args) >= 2 && $this->getArgument(0) == 'help') {
\r
57 $command = $this->getArgument(1);
\r
59 array_shift($this->args);
\r
60 array_shift($this->args);
\r
61 } elseif (count($this->args) >= 1) {
\r
62 $command = $this->getArgument(0);
\r
63 array_shift($this->args);
\r
66 if (is_null($command)) {
\r
67 $this->out($this->getHelp());
\r
71 $console = $this->getSubConsole($command);
\r
74 $console->setOption($this->customHelpOptions, true);
\r
77 return $console->execute();
\r
80 private function getSubConsole($command)
\r
82 if ($this->getOption('v')) {
\r
83 $this->out('Command: ' . $command);
\r
86 $subargs = $this->args;
\r
87 array_unshift($subargs, $this->executable);
\r
92 case 'config' : $subconsole = new Console\Config($subargs);
\r
94 case 'createdoxygen' : $subconsole = new Console\CreateDoxygen($subargs);
\r
96 case 'docbloxerrorchecker' : $subconsole = new Console\DocBloxErrorChecker($subargs);
\r
98 case 'globalcommunityblock': $subconsole = new Console\GlobalCommunityBlock($subargs);
\r
101 throw new \Asika\SimpleConsole\CommandArgsException('Command ' . $command . ' doesn\'t exist');
\r
104 foreach ($this->options as $name => $value) {
\r
105 $subconsole->setOption($name, $value);
\r
108 return $subconsole;
\r