3 namespace Friendica\Core;
6 * Description of Console
8 * @author Hypolite Petovan <mrpetovan@gmail.com>
10 class Console extends \Asika\SimpleConsole\Console
12 // Disables the default help handling
13 protected $helpOptions = [];
14 protected $customHelpOptions = ['h', 'help', '?'];
16 protected $subConsoles = [
17 'config' => __NAMESPACE__ . '\Console\Config',
18 'createdoxygen' => __NAMESPACE__ . '\Console\CreateDoxygen',
19 'docbloxerrorchecker' => __NAMESPACE__ . '\Console\DocBloxErrorChecker',
20 'dbstructure' => __NAMESPACE__ . '\Console\DatabaseStructure',
21 'extract' => __NAMESPACE__ . '\Console\Extract',
22 'globalcommunityblock' => __NAMESPACE__ . '\Console\GlobalCommunityBlock',
23 'globalcommunitysilence' => __NAMESPACE__ . '\Console\GlobalCommunitySilence',
24 'archivecontact' => __NAMESPACE__ . '\Console\ArchiveContact',
25 'autoinstall' => __NAMESPACE__ . '\Console\AutomaticInstallation',
26 'maintenance' => __NAMESPACE__ . '\Console\Maintenance',
27 'newpassword' => __NAMESPACE__ . '\Console\NewPassword',
28 'php2po' => __NAMESPACE__ . '\Console\PhpToPo',
29 'po2php' => __NAMESPACE__ . '\Console\PoToPhp',
30 'typo' => __NAMESPACE__ . '\Console\Typo',
31 'postupdate' => __NAMESPACE__ . '\Console\PostUpdate',
34 protected function getHelp()
37 Usage: bin/console [--version] [-h|--help|-?] <command> [<args>] [-v]
40 config Edit site config
41 createdoxygen Generate Doxygen headers
42 dbstructure Do database updates
43 docbloxerrorchecker Check the file tree for DocBlox errors
44 extract Generate translation string file for the Friendica project (deprecated)
45 globalcommunityblock Block remote profile from interacting with this node
46 globalcommunitysilence Silence remote profile from global community page
47 archivecontact Archive a contact when you know that it isn't existing anymore
48 help Show help about a command, e.g (bin/console help config)
49 autoinstall Starts automatic installation of friendica based on values from htconfig.php
50 maintenance Set maintenance mode for this node
51 newpassword Set a new password for a given user
52 php2po Generate a messages.po file from a strings.php file
53 po2php Generate a strings.php file from a messages.po file
54 typo Checks for parse errors in Friendica files
55 postupdate Execute pending post update scripts (can last days)
58 -h|--help|-? Show help information
59 -v Show more debug information.
64 protected function doExecute()
66 if ($this->getOption('v')) {
67 $this->out('Executable: ' . $this->executable);
68 $this->out('Arguments: ' . var_export($this->args, true));
69 $this->out('Options: ' . var_export($this->options, true));
76 if ($this->getOption('version')) {
77 $this->out('Friendica Console version ' . FRIENDICA_VERSION);
80 } elseif ((count($this->options) === 0 || $this->getOption($this->customHelpOptions) === true || $this->getOption($this->customHelpOptions) === 1) && count($this->args) === 0
83 } elseif (count($this->args) >= 2 && $this->getArgument(0) == 'help') {
84 $command = $this->getArgument(1);
86 array_shift($this->args);
87 array_shift($this->args);
88 } elseif (count($this->args) >= 1) {
89 $command = $this->getArgument(0);
90 array_shift($this->args);
93 if (is_null($command)) {
94 $this->out($this->getHelp());
98 $console = $this->getSubConsole($command);
101 $console->setOption($this->customHelpOptions, true);
104 return $console->execute();
107 private function getSubConsole($command)
109 if ($this->getOption('v')) {
110 $this->out('Command: ' . $command);
113 if (!isset($this->subConsoles[$command])) {
114 throw new \Asika\SimpleConsole\CommandArgsException('Command ' . $command . ' doesn\'t exist');
117 $subargs = $this->args;
118 array_unshift($subargs, $this->executable);
120 $className = $this->subConsoles[$command];
122 $subconsole = new $className($subargs);
124 foreach ($this->options as $name => $value) {
125 $subconsole->setOption($name, $value);