From 5ce53845c0ff39215550ec56e0f9ae739b5997f5 Mon Sep 17 00:00:00 2001 From: Timm Friebe Date: Thu, 28 Mar 2024 20:50:54 +0100 Subject: [PATCH] Fix lang.IndexOutOfBoundsException (Undefined array key 1) --- src/main/php/xp/command/CmdRunner.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/php/xp/command/CmdRunner.class.php b/src/main/php/xp/command/CmdRunner.class.php index 29776b4..9fd738a 100755 --- a/src/main/php/xp/command/CmdRunner.class.php +++ b/src/main/php/xp/command/CmdRunner.class.php @@ -95,9 +95,12 @@ protected function commandUsage(Type $type) { if ('' === (string)$comment) { $markdown= '# '.$type->name()."\n\n"; $text= ''; + } else if (false === ($p= strpos($comment, "\n"))) { + $markdown= '# '.$comment."\n\n"; + $text= ''; } else { - @list($headline, $text)= explode("\n", $comment, 2); - $markdown= '# '.ltrim($headline, ' #')."\n\n"; + $markdown= '# '.ltrim(substr($comment, 0, $p), ' #')."\n\n"; + $text= substr($comment, $p + 1); } $markdown.= "- Usage\n ```sh\n$ xp cmd ".Commands::nameOf($type->class());