Skip to content

Commit 76ec9dc

Browse files
update method help for ICanError interface
1 parent aa666fe commit 76ec9dc

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

Plugin/Commands/HelpSystem/HelpCommand.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ This statement can ONLY be used after a statement supporting the "{extender.Exte
181181
""";
182182
}
183183

184-
private static string GetKeywordHelpPage()
184+
/*private static string GetKeywordHelpPage()
185185
{
186186
return
187187
"""
@@ -212,7 +212,7 @@ repeat 10
212212
.Select(k => $"{k.KeywordName} - {k.Description}")
213213
.JoinStrings("\n");
214214
215-
/*var keywords = KeywordToken.KeywordInfo.Keys.Select(k => $"\n> {k}").JoinStrings();
215+
var keywords = KeywordToken.KeywordInfo.Keys.Select(k => $"\n> {k}").JoinStrings();
216216
217217
return
218218
"""
@@ -238,8 +238,8 @@ repeat 10
238238
239239
Here is a list of all keywords available in SER:
240240
(each of them is of course searchable using 'serhelp keywordName')
241-
""" + keywords;*/
242-
}
241+
""" + keywords;
242+
}*/
243243

244244
private static string GetFlagHelpPage()
245245
{
@@ -526,7 +526,7 @@ private static string GetMethodHelp(Method method)
526526
break;
527527
case ReferenceReturningMethod refMethod:
528528
sb.AppendLine();
529-
sb.AppendLine($"This method returns a reference to {refMethod.ReturnType.Name} object, which can be saved or used directly.\n" +
529+
sb.AppendLine($"This method returns a reference to {refMethod.ReturnType.GetAccurateName()} object, which can be saved or used directly.\n" +
530530
$"References represent an object which cannot be fully represented in text.\n" +
531531
$"If you wish to use that reference further, find methods supporting references of this type.");
532532
break;
@@ -561,16 +561,18 @@ private static string GetMethodHelp(Method method)
561561
sb.AppendLine("This method expects the following arguments:");
562562
for (var index = 0; index < method.ExpectedArguments.Length; index++)
563563
{
564+
if (index > 0) sb.AppendLine();
565+
564566
var argument = method.ExpectedArguments[index];
565-
var optionalArgPrefix = argument.DefaultValue is null ? " optional" : "";
567+
var optionalArgPrefix = argument.DefaultValue is not null ? " optional" : "";
566568
sb.AppendLine($"({index + 1}){optionalArgPrefix} '{argument.Name}' argument");
567569

568570
if (argument.Description is not null)
569571
{
570572
sb.AppendLine($" - Description: {argument.Description}");
571573
}
572574

573-
sb.AppendLine($" - Expected value: {argument.InputDescription}");
575+
sb.AppendLine($" - Expected value: {argument.InputDescription.Replace("\n", "\n\t")}");
574576

575577
if (argument.DefaultValue is {} defVal)
576578
{
@@ -583,8 +585,13 @@ private static string GetMethodHelp(Method method)
583585
" - This argument consumes all remaining values; this means that every value provided AFTER " +
584586
"this one will ALSO count towards this argument's values.");
585587
}
588+
}
586589

590+
if (method is ICanError errorMethod)
591+
{
587592
sb.AppendLine();
593+
sb.AppendLine("This method defines custom errors:");
594+
sb.AppendLine(errorMethod.ErrorReasons.Select(e => $"> {e}").JoinStrings("\n"));
588595
}
589596

590597
/*if (method.ExpectedArguments.All(arg => arg.AdditionalDescription is null))

0 commit comments

Comments
 (0)