diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2019-07-10 13:05:47 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-10 13:05:47 +0300 |
commit | b4d39182f6906b2ca9f1a78eed9d7755d9f3345e (patch) | |
tree | 2a3998176dd0d6ad31dba20ff17861a7e31d658b /lib/Chat | |
parent | 4bd464b5c006c2ff7bcdbdc0813f8ff9593bf9ec (diff) | |
parent | 4d693f0b5a8925f8e3780a49bbb3201d67e5d00b (diff) |
Merge pull request #1918 from nextcloud/feature/noid/support-symfony-command-line-commands-with-help
Support symfony command lines with --help
Diffstat (limited to 'lib/Chat')
-rw-r--r-- | lib/Chat/Command/Executor.php | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/lib/Chat/Command/Executor.php b/lib/Chat/Command/Executor.php index d5e316dbd..cfe8d8e53 100644 --- a/lib/Chat/Command/Executor.php +++ b/lib/Chat/Command/Executor.php @@ -121,7 +121,16 @@ class Executor { $response = trim($response); if (strpos($response, "\n")) { - $helps[] = substr($response, 0, strpos($response, "\n")); + $tempHelp = substr($response, 0, strpos($response, "\n")); + if ($tempHelp === 'Description:') { + $hasHelpSection = strpos($response, "\nHelp:\n"); + if ($hasHelpSection !== false) { + // Symfony console command with --help detected + $tempHelp = substr($response, $hasHelpSection + 7); + $tempHelp = substr($tempHelp, 0, strpos($tempHelp, "\n")); + } + } + $helps[] = $tempHelp; } else { $helps[] = $response; } @@ -140,7 +149,17 @@ class Executor { $input = explode(' ', $arguments, 2); if (count($input) === 1) { $command = $this->commandService->find('', $arguments); - return $this->execShell($room, $message, $command, '--help'); + $response = $this->execShell($room, $message, $command, '--help'); + + if (strpos($response, 'Description:') === 0) { + $hasHelpSection = strpos($response, "\nHelp:\n"); + if ($hasHelpSection !== false) { + // Symfony console command with --help detected + $response = substr($response, $hasHelpSection + 7); + } + } + + return $response; } [$app, $cmd] = $input; |