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 'cache' => __NAMESPACE__ . '\Console\Cache',
18 'config' => __NAMESPACE__ . '\Console\Config',
19 'createdoxygen' => __NAMESPACE__ . '\Console\CreateDoxygen',
20 'docbloxerrorchecker' => __NAMESPACE__ . '\Console\DocBloxErrorChecker',
21 'dbstructure' => __NAMESPACE__ . '\Console\DatabaseStructure',
22 'extract' => __NAMESPACE__ . '\Console\Extract',
23 'globalcommunityblock' => __NAMESPACE__ . '\Console\GlobalCommunityBlock',
24 'globalcommunitysilence' => __NAMESPACE__ . '\Console\GlobalCommunitySilence',
25 'archivecontact' => __NAMESPACE__ . '\Console\ArchiveContact',
26 'autoinstall' => __NAMESPACE__ . '\Console\AutomaticInstallation',
27 'maintenance' => __NAMESPACE__ . '\Console\Maintenance',
28 'newpassword' => __NAMESPACE__ . '\Console\NewPassword',
29 'php2po' => __NAMESPACE__ . '\Console\PhpToPo',
30 'po2php' => __NAMESPACE__ . '\Console\PoToPhp',
31 'typo' => __NAMESPACE__ . '\Console\Typo',
32 'postupdate' => __NAMESPACE__ . '\Console\PostUpdate',
33 'storage' => __NAMESPACE__ . '\Console\Storage',
36 protected function getHelp()
39 Usage: bin/console [--version] [-h|--help|-?] <command> [<args>] [-v]
42 cache Manage node cache
43 config Edit site config
44 createdoxygen Generate Doxygen headers
45 dbstructure Do database updates
46 docbloxerrorchecker Check the file tree for DocBlox errors
47 extract Generate translation string file for the Friendica project (deprecated)
48 globalcommunityblock Block remote profile from interacting with this node
49 globalcommunitysilence Silence remote profile from global community page
50 archivecontact Archive a contact when you know that it isn't existing anymore
51 help Show help about a command, e.g (bin/console help config)
52 autoinstall Starts automatic installation of friendica based on values from htconfig.php
53 maintenance Set maintenance mode for this node
54 newpassword Set a new password for a given user
55 php2po Generate a messages.po file from a strings.php file
56 po2php Generate a strings.php file from a messages.po file
57 typo Checks for parse errors in Friendica files
58 postupdate Execute pending post update scripts (can last days)
59 storage Manage storage backend
62 -h|--help|-? Show help information
63 -v Show more debug information.
68 protected function doExecute()
70 if ($this->getOption('v')) {
71 $this->out('Executable: ' . $this->executable);
72 $this->out('Arguments: ' . var_export($this->args, true));
73 $this->out('Options: ' . var_export($this->options, true));
79 if ($this->getOption('version')) {
80 $this->out('Friendica Console version ' . FRIENDICA_VERSION);
83 } elseif ((count($this->options) === 0 || $this->getOption($this->customHelpOptions) === true || $this->getOption($this->customHelpOptions) === 1) && count($this->args) === 0
85 } elseif (count($this->args) >= 2 && $this->getArgument(0) == 'help') {
86 $command = $this->getArgument(1);
88 array_shift($this->args);
89 array_shift($this->args);
90 } elseif (count($this->args) >= 1) {
91 $command = $this->getArgument(0);
92 array_shift($this->args);
95 if (is_null($command)) {
96 $this->out($this->getHelp());
100 $console = $this->getSubConsole($command);
103 $console->setOption($this->customHelpOptions, true);
106 return $console->execute();
109 private function getSubConsole($command)
111 if ($this->getOption('v')) {
112 $this->out('Command: ' . $command);
115 if (!isset($this->subConsoles[$command])) {
116 throw new \Asika\SimpleConsole\CommandArgsException('Command ' . $command . ' doesn\'t exist');
119 $subargs = $this->args;
120 array_unshift($subargs, $this->executable);
122 $className = $this->subConsoles[$command];
124 /** @var Console $subconsole */
125 $subconsole = new $className($subargs);
127 foreach ($this->options as $name => $value) {
128 $subconsole->setOption($name, $value);