ServerPack: ServerUsageLines, a server's own /rserver usage lines
An optional hook, collected once in the constructor. ServerPackCommands.Usage appends a server's lines (trimmed, blanks dropped) after the shared two, and "/rserver help" and an unknown word print them all. A server without the hook prints exactly the two lines it always has (pinned on Coldeve). ServerProjectsTests.PluginsDir is internal so other tests can share it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
c085c16e15
commit
8ceba81070
4 changed files with 49 additions and 9 deletions
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using RynthCore.Plugin.ServerPack;
|
||||
using RynthCore.Plugin.Shared;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
|
@ -50,6 +51,25 @@ internal static class ServerPackCommandsTests
|
|||
Check.Eq(usage.Length, 2, "two usage lines");
|
||||
Check.True(usage[0].Contains("/rserver [show|hide|toggle]") && usage[1].Contains("/rserver auto|on|off"), "the usage names every verb");
|
||||
Check.Eq(ServerPackCommands.Unknown("wobble"), "Unknown '/rserver wobble'.", "an unknown word");
|
||||
|
||||
// A server without ServerUsageLines (Coldeve) prints exactly the two shared lines, byte for byte.
|
||||
string[] pinned =
|
||||
{
|
||||
"/rserver [show|hide|toggle] - the Coldeve server card (also in the Mini Remote's Char section).",
|
||||
"/rserver info - what is known about Coldeve; /rserver auto|on|off - this character's override.",
|
||||
};
|
||||
Check.Eq(string.Join("\n", usage), string.Join("\n", pinned), "hookless usage is unchanged");
|
||||
Check.Eq(string.Join("\n", ServerPackCommands.Usage("Coldeve", new List<string>())), string.Join("\n", pinned), "no own lines: unchanged");
|
||||
Check.Eq(string.Join("\n", ServerPackCommands.Usage("Coldeve", new List<string> { "", " " })), string.Join("\n", pinned), "blank own lines are dropped");
|
||||
string coldeve = string.Join("\n", System.IO.Directory.GetFiles(System.IO.Path.Combine(ServerProjectsTests.PluginsDir(), "RynthCore.Plugin.RynthColdeve"), "*.cs", System.IO.SearchOption.AllDirectories)
|
||||
.Where(f => !f.Contains("\\obj\\") && !f.Contains("\\bin\\")).Select(System.IO.File.ReadAllText));
|
||||
Check.False(coldeve.Contains("ServerUsageLines", StringComparison.Ordinal), "Coldeve has no ServerUsageLines (so the pin above is what it prints)");
|
||||
|
||||
// A server's own lines follow the shared two, which stay first and unchanged.
|
||||
string[] own = ServerPackCommands.Usage("Coldeve", new List<string> { " /rserver x - one more line " });
|
||||
Check.Eq(own.Length, 3, "an own line is appended");
|
||||
Check.Eq(own[2], "/rserver x - one more line", "trimmed");
|
||||
Check.True(own[0] == pinned[0] && own[1] == pinned[1], "the shared two come first, unchanged");
|
||||
}
|
||||
|
||||
private static void Queue()
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ internal static class ServerProjectsTests
|
|||
"levistras",
|
||||
};
|
||||
|
||||
private static string PluginsDir()
|
||||
internal static string PluginsDir()
|
||||
{
|
||||
string? dir = AppContext.BaseDirectory;
|
||||
while (dir != null && !Directory.Exists(Path.Combine(dir, "Plugins", "Shared", "ServerPack")))
|
||||
|
|
|
|||
Loading…
Reference in a new issue