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 $subConsoles = [
\r
17 'config' => __NAMESPACE__ . '\Console\Config',
\r
18 'createdoxygen' => __NAMESPACE__ . '\Console\CreateDoxygen',
\r
19 'docbloxerrorchecker' => __NAMESPACE__ . '\Console\DocBloxErrorChecker',
\r
20 'dbstructure' => __NAMESPACE__ . '\Console\DatabaseStructure',
\r
21 'extract' => __NAMESPACE__ . '\Console\Extract',
\r
22 'globalcommunityblock' => __NAMESPACE__ . '\Console\GlobalCommunityBlock',
\r
23 'globalcommunitysilence' => __NAMESPACE__ . '\Console\GlobalCommunitySilence',
\r
24 'maintenance' => __NAMESPACE__ . '\Console\Maintenance',
\r
25 'php2po' => __NAMESPACE__ . '\Console\PhpToPo',
\r
26 'po2php' => __NAMESPACE__ . '\Console\PoToPhp',
\r
27 'typo' => __NAMESPACE__ . '\Console\Typo',
\r
30 protected function getHelp()
\r
33 Usage: bin/console [--version] [-h|--help|-?] <command> [<args>] [-v]
\r
36 config Edit site config
\r
37 createdoxygen Generate Doxygen headers
\r
38 dbstructure Do database updates
\r
39 docbloxerrorchecker Check the file tree for DocBlox errors
\r
40 extract Generate translation string file for the Friendica project (deprecated)
\r
41 globalcommunityblock Block remote profile from interacting with this node
\r
42 globalcommunitysilence Silence remote profile from global community page
\r
43 help Show help about a command, e.g (bin/console help config)
\r
44 maintenance Set maintenance mode for this node
\r
45 php2po Generate a messages.po file from a strings.php file
\r
46 po2php Generate a strings.php file from a messages.po file
\r
47 typo Checks for parse errors in Friendica files
\r
50 -h|--help|-? Show help information
\r
51 -v Show more debug information.
\r
56 protected function doExecute()
\r
58 if ($this->getOption('v')) {
\r
59 $this->out('Executable: ' . $this->executable);
\r
60 $this->out('Arguments: ' . var_export($this->args, true));
\r
61 $this->out('Options: ' . var_export($this->options, true));
\r
68 if ($this->getOption('version')) {
\r
69 $this->out('Friendica Console version ' . FRIENDICA_VERSION);
\r
72 } elseif ((count($this->options) === 0 || $this->getOption($this->customHelpOptions) === true || $this->getOption($this->customHelpOptions) === 1) && count($this->args) === 0
\r
75 } elseif (count($this->args) >= 2 && $this->getArgument(0) == 'help') {
\r
76 $command = $this->getArgument(1);
\r
78 array_shift($this->args);
\r
79 array_shift($this->args);
\r
80 } elseif (count($this->args) >= 1) {
\r
81 $command = $this->getArgument(0);
\r
82 array_shift($this->args);
\r
85 if (is_null($command)) {
\r
86 $this->out($this->getHelp());
\r
90 $console = $this->getSubConsole($command);
\r
93 $console->setOption($this->customHelpOptions, true);
\r
96 return $console->execute();
\r
99 private function getSubConsole($command)
\r
101 if ($this->getOption('v')) {
\r
102 $this->out('Command: ' . $command);
\r
105 if (!isset($this->subConsoles[$command])) {
\r
106 throw new \Asika\SimpleConsole\CommandArgsException('Command ' . $command . ' doesn\'t exist');
\r
109 $subargs = $this->args;
\r
110 array_unshift($subargs, $this->executable);
\r
112 $className = $this->subConsoles[$command];
\r
114 $subconsole = new $className($subargs);
\r
116 foreach ($this->options as $name => $value) {
\r
117 $subconsole->setOption($name, $value);
\r
120 return $subconsole;
\r