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',
35 protected function getHelp()
38 Usage: bin/console [--version] [-h|--help|-?] <command> [<args>] [-v]
41 cache Manage node cache
42 config Edit site config
43 createdoxygen Generate Doxygen headers
44 dbstructure Do database updates
45 docbloxerrorchecker Check the file tree for DocBlox errors
46 extract Generate translation string file for the Friendica project (deprecated)
47 globalcommunityblock Block remote profile from interacting with this node
48 globalcommunitysilence Silence remote profile from global community page
49 archivecontact Archive a contact when you know that it isn't existing anymore
50 help Show help about a command, e.g (bin/console help config)
51 autoinstall Starts automatic installation of friendica based on values from htconfig.php
52 maintenance Set maintenance mode for this node
53 newpassword Set a new password for a given user
54 php2po Generate a messages.po file from a strings.php file
55 po2php Generate a strings.php file from a messages.po file
56 typo Checks for parse errors in Friendica files
57 postupdate Execute pending post update scripts (can last days)
60 -h|--help|-? Show help information
61 -v Show more debug information.
66 protected function doExecute()
68 if ($this->getOption('v')) {
69 $this->out('Executable: ' . $this->executable);
70 $this->out('Arguments: ' . var_export($this->args, true));
71 $this->out('Options: ' . var_export($this->options, true));
78 if ($this->getOption('version')) {
79 $this->out('Friendica Console version ' . FRIENDICA_VERSION);
82 } 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 $subconsole = new $className($subargs);
126 foreach ($this->options as $name => $value) {
127 $subconsole->setOption($name, $value);