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 function getHelp()
19 Usage: bin/console [--version] [-h|--help|-?] <command> [<args>] [-v]
22 cache Manage node cache
23 config Edit site config
24 createdoxygen Generate Doxygen headers
25 dbstructure Do database updates
26 docbloxerrorchecker Check the file tree for DocBlox errors
27 extract Generate translation string file for the Friendica project (deprecated)
28 globalcommunityblock Block remote profile from interacting with this node
29 globalcommunitysilence Silence remote profile from global community page
30 archivecontact Archive a contact when you know that it isn't existing anymore
31 help Show help about a command, e.g (bin/console help config)
32 autoinstall Starts automatic installation of friendica based on values from htconfig.php
33 maintenance Set maintenance mode for this node
34 newpassword Set a new password for a given user
35 php2po Generate a messages.po file from a strings.php file
36 po2php Generate a strings.php file from a messages.po file
37 typo Checks for parse errors in Friendica files
38 postupdate Execute pending post update scripts (can last days)
39 serverblock Manage blocked servers
40 storage Manage storage backend
43 -h|--help|-? Show help information
44 -v Show more debug information.
49 protected $subConsoles = [
50 'cache' => __NAMESPACE__ . '\Console\Cache',
51 'config' => __NAMESPACE__ . '\Console\Config',
52 'createdoxygen' => __NAMESPACE__ . '\Console\CreateDoxygen',
53 'docbloxerrorchecker' => __NAMESPACE__ . '\Console\DocBloxErrorChecker',
54 'dbstructure' => __NAMESPACE__ . '\Console\DatabaseStructure',
55 'extract' => __NAMESPACE__ . '\Console\Extract',
56 'globalcommunityblock' => __NAMESPACE__ . '\Console\GlobalCommunityBlock',
57 'globalcommunitysilence' => __NAMESPACE__ . '\Console\GlobalCommunitySilence',
58 'archivecontact' => __NAMESPACE__ . '\Console\ArchiveContact',
59 'autoinstall' => __NAMESPACE__ . '\Console\AutomaticInstallation',
60 'maintenance' => __NAMESPACE__ . '\Console\Maintenance',
61 'newpassword' => __NAMESPACE__ . '\Console\NewPassword',
62 'php2po' => __NAMESPACE__ . '\Console\PhpToPo',
63 'po2php' => __NAMESPACE__ . '\Console\PoToPhp',
64 'typo' => __NAMESPACE__ . '\Console\Typo',
65 'postupdate' => __NAMESPACE__ . '\Console\PostUpdate',
66 'serverblock' => __NAMESPACE__ . '\Console\ServerBlock',
67 'storage' => __NAMESPACE__ . '\Console\Storage',
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);