3 namespace Friendica\Core;
6 * Description of Console
8 * @author Hypolite Petovan <hypolite@mrpetovan.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 'blockedservers' => __NAMESPACE__ . '\Console\BlockedServers',
18 'cache' => __NAMESPACE__ . '\Console\Cache',
19 'config' => __NAMESPACE__ . '\Console\Config',
20 'createdoxygen' => __NAMESPACE__ . '\Console\CreateDoxygen',
21 'docbloxerrorchecker' => __NAMESPACE__ . '\Console\DocBloxErrorChecker',
22 'dbstructure' => __NAMESPACE__ . '\Console\DatabaseStructure',
23 'extract' => __NAMESPACE__ . '\Console\Extract',
24 'globalcommunityblock' => __NAMESPACE__ . '\Console\GlobalCommunityBlock',
25 'globalcommunitysilence' => __NAMESPACE__ . '\Console\GlobalCommunitySilence',
26 'archivecontact' => __NAMESPACE__ . '\Console\ArchiveContact',
27 'autoinstall' => __NAMESPACE__ . '\Console\AutomaticInstallation',
28 'maintenance' => __NAMESPACE__ . '\Console\Maintenance',
29 'newpassword' => __NAMESPACE__ . '\Console\NewPassword',
30 'php2po' => __NAMESPACE__ . '\Console\PhpToPo',
31 'po2php' => __NAMESPACE__ . '\Console\PoToPhp',
32 'typo' => __NAMESPACE__ . '\Console\Typo',
33 'postupdate' => __NAMESPACE__ . '\Console\PostUpdate',
34 'storage' => __NAMESPACE__ . '\Console\Storage',
37 protected function getHelp()
40 Usage: bin/console [--version] [-h|--help|-?] <command> [<args>] [-v]
43 blockedservers Manage blocked servers
44 cache Manage node cache
45 config Edit site config
46 createdoxygen Generate Doxygen headers
47 dbstructure Do database updates
48 docbloxerrorchecker Check the file tree for DocBlox errors
49 extract Generate translation string file for the Friendica project (deprecated)
50 globalcommunityblock Block remote profile from interacting with this node
51 globalcommunitysilence Silence remote profile from global community page
52 archivecontact Archive a contact when you know that it isn't existing anymore
53 help Show help about a command, e.g (bin/console help config)
54 autoinstall Starts automatic installation of friendica based on values from htconfig.php
55 maintenance Set maintenance mode for this node
56 newpassword Set a new password for a given user
57 php2po Generate a messages.po file from a strings.php file
58 po2php Generate a strings.php file from a messages.po file
59 typo Checks for parse errors in Friendica files
60 postupdate Execute pending post update scripts (can last days)
61 storage Manage storage backend
64 -h|--help|-? Show help information
65 -v Show more debug information.
70 protected function doExecute()
72 if ($this->getOption('v')) {
73 $this->out('Executable: ' . $this->executable);
74 $this->out('Arguments: ' . var_export($this->args, true));
75 $this->out('Options: ' . var_export($this->options, true));
81 if ($this->getOption('version')) {
82 $this->out('Friendica Console version ' . FRIENDICA_VERSION);
85 } elseif ((count($this->options) === 0 || $this->getOption($this->customHelpOptions) === true || $this->getOption($this->customHelpOptions) === 1) && count($this->args) === 0
87 } elseif (count($this->args) >= 2 && $this->getArgument(0) == 'help') {
88 $command = $this->getArgument(1);
90 array_shift($this->args);
91 array_shift($this->args);
92 } elseif (count($this->args) >= 1) {
93 $command = $this->getArgument(0);
94 array_shift($this->args);
97 if (is_null($command)) {
98 $this->out($this->getHelp());
102 $console = $this->getSubConsole($command);
105 $console->setOption($this->customHelpOptions, true);
108 return $console->execute();
111 private function getSubConsole($command)
113 if ($this->getOption('v')) {
114 $this->out('Command: ' . $command);
117 if (!isset($this->subConsoles[$command])) {
118 throw new \Asika\SimpleConsole\CommandArgsException('Command ' . $command . ' doesn\'t exist');
121 $subargs = $this->args;
122 array_unshift($subargs, $this->executable);
124 $className = $this->subConsoles[$command];
126 /** @var Console $subconsole */
127 $subconsole = new $className($subargs);
129 foreach ($this->options as $name => $value) {
130 $subconsole->setOption($name, $value);