3 namespace Friendica\Core;
8 * Description of Console
10 * @author Hypolite Petovan <hypolite@mrpetovan.com>
12 class Console extends \Asika\SimpleConsole\Console
14 // Disables the default help handling
15 protected $helpOptions = [];
16 protected $customHelpOptions = ['h', 'help', '?'];
18 protected function getHelp()
21 Usage: bin/console [--version] [-h|--help|-?] <command> [<args>] [-v]
24 cache Manage node cache
25 config Edit site config
26 createdoxygen Generate Doxygen headers
27 dbstructure Do database updates
28 docbloxerrorchecker Check the file tree for DocBlox errors
29 extract Generate translation string file for the Friendica project (deprecated)
30 globalcommunityblock Block remote profile from interacting with this node
31 globalcommunitysilence Silence remote profile from global community page
32 archivecontact Archive a contact when you know that it isn't existing anymore
33 help Show help about a command, e.g (bin/console help config)
34 autoinstall Starts automatic installation of friendica based on values from htconfig.php
35 maintenance Set maintenance mode for this node
36 newpassword Set a new password for a given user
37 php2po Generate a messages.po file from a strings.php file
38 po2php Generate a strings.php file from a messages.po file
39 typo Checks for parse errors in Friendica files
40 postupdate Execute pending post update scripts (can last days)
41 serverblock Manage blocked servers
42 storage Manage storage backend
45 -h|--help|-? Show help information
46 -v Show more debug information.
51 protected $subConsoles = [
52 'cache' => Friendica\Console\Cache::class,
53 'config' => Friendica\Console\Config::class,
54 'createdoxygen' => Friendica\Console\CreateDoxygen::class,
55 'docbloxerrorchecker' => Friendica\Console\DocBloxErrorChecker::class,
56 'dbstructure' => Friendica\Console\DatabaseStructure::class,
57 'extract' => Friendica\Console\Extract::class,
58 'globalcommunityblock' => Friendica\Console\GlobalCommunityBlock::class,
59 'globalcommunitysilence' => Friendica\Console\GlobalCommunitySilence::class,
60 'archivecontact' => Friendica\Console\ArchiveContact::class,
61 'autoinstall' => Friendica\Console\AutomaticInstallation::class,
62 'maintenance' => Friendica\Console\Maintenance::class,
63 'newpassword' => Friendica\Console\NewPassword::class,
64 'php2po' => Friendica\Console\PhpToPo::class,
65 'po2php' => Friendica\Console\PoToPhp::class,
66 'typo' => Friendica\Console\Typo::class,
67 'postupdate' => Friendica\Console\PostUpdate::class,
68 'serverblock' => Friendica\Console\ServerBlock::class,
69 'storage' => Friendica\Console\Storage::class,
72 protected function doExecute()
74 if ($this->getOption('v')) {
75 $this->out('Executable: ' . $this->executable);
76 $this->out('Arguments: ' . var_export($this->args, true));
77 $this->out('Options: ' . var_export($this->options, true));
83 if ($this->getOption('version')) {
84 $this->out('Friendica Console version ' . FRIENDICA_VERSION);
87 } elseif ((count($this->options) === 0 || $this->getOption($this->customHelpOptions) === true || $this->getOption($this->customHelpOptions) === 1) && count($this->args) === 0
89 } elseif (count($this->args) >= 2 && $this->getArgument(0) == 'help') {
90 $command = $this->getArgument(1);
92 array_shift($this->args);
93 array_shift($this->args);
94 } elseif (count($this->args) >= 1) {
95 $command = $this->getArgument(0);
96 array_shift($this->args);
99 if (is_null($command)) {
100 $this->out($this->getHelp());
104 $console = $this->getSubConsole($command);
107 $console->setOption($this->customHelpOptions, true);
110 return $console->execute();
113 private function getSubConsole($command)
115 if ($this->getOption('v')) {
116 $this->out('Command: ' . $command);
119 if (!isset($this->subConsoles[$command])) {
120 throw new \Asika\SimpleConsole\CommandArgsException('Command ' . $command . ' doesn\'t exist');
123 $subargs = $this->args;
124 array_unshift($subargs, $this->executable);
126 $className = $this->subConsoles[$command];
128 /** @var Console $subconsole */
129 $subconsole = new $className($subargs);
131 foreach ($this->options as $name => $value) {
132 $subconsole->setOption($name, $value);