Skip to content

Commit 2b7672e

Browse files
committed
addressed comments from pr, chat command usage now supports multiple outputs.
1 parent 8f95685 commit 2b7672e

11 files changed

+37
-42
lines changed

NebulaWorld/Chat/Commands/ClearCommandHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ public void Execute(ChatWindow window, string[] parameters)
1919
window.ClearChat(message => message.MessageType.IsCommandMessage());
2020
}
2121

22-
public string GetUsage()
22+
public string[] GetUsage()
2323
{
24-
return $"[all|commands]";
24+
return new string[] { $"[all|commands]" };
2525
}
2626

2727
public string GetDescription()

NebulaWorld/Chat/Commands/HelpCommandHandler.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,16 @@ private static string GetCommandDetailsOutput(string commandName)
4343
string aliasList = ChatCommandRegistry.GetCommandAliases(commandName).Join(FullCommandName);
4444

4545
StringBuilder sb = new StringBuilder();
46+
foreach(string usage in handler.GetUsage())
47+
{
48+
sb.Append($"Usage: {FullCommandName(commandName)} {usage}\n");
49+
}
50+
string usageString = sb.ToString();
51+
52+
sb.Clear();
4653
sb.Append($"Command {commandName} - {handler.GetDescription()}\n");
4754
sb.Append($"Aliases: {aliasList}\n");
48-
sb.Append($"Usage: {FullCommandName(commandName)} {handler.GetUsage()}");
55+
sb.Append($"{usageString}");
4956
return sb.ToString();
5057
}
5158

@@ -82,9 +89,9 @@ public string GetDescription()
8289
return "Get list of existing commands and their usage";
8390
}
8491

85-
public string GetUsage()
92+
public string[] GetUsage()
8693
{
87-
return "[command name]";
94+
return new string[] { "[command name]" };
8895
}
8996
}
9097
}

NebulaWorld/Chat/Commands/IChatCommandHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public interface IChatCommandHandler
1616
/// <summary>
1717
/// Provide argument usage (If needed) without starting with command name
1818
/// </summary>
19-
string GetUsage();
19+
string[] GetUsage();
2020
}
2121

2222
public class ChatCommandUsageException : Exception

NebulaWorld/Chat/Commands/InfoCommandHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ public string GetDescription()
151151
return "Get information about server";
152152
}
153153

154-
public string GetUsage()
154+
public string[] GetUsage()
155155
{
156-
return "[full]";
156+
return new string[] { "[full]" };
157157
}
158158
}
159159
}

NebulaWorld/Chat/Commands/NavigateCommandHandler.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,17 @@ public void Execute(ChatWindow window, string[] parameters)
9191
}
9292
}
9393

94-
window.SendLocalChatMessage("Failed to start navigation, please check your input.", ChatMessageType.CommandOutputMessage);
94+
window.SendLocalChatMessage("Failed to start navigation, please check your input.", ChatMessageType.CommandErrorMessage);
9595
}
9696

9797
public string GetDescription()
9898
{
9999
return "Start navigating to a specified destination";
100100
}
101-
public string GetUsage()
101+
public string[] GetUsage()
102102
{
103-
return "[planet name | planet id | star name | star id | clear]\r\nUsage: /n player [player id | playr name]";
103+
return new string[] { "<planet name | planet id | star name | star id | clear>",
104+
"player <player id | player name>" };
104105
}
105106
}
106107
}

NebulaWorld/Chat/Commands/PingCommandHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ public string GetDescription()
3737
return "Test command";
3838
}
3939

40-
public string GetUsage()
40+
public string[] GetUsage()
4141
{
42-
return "[time delay (seconds)]";
42+
return new string[] { "[time delay (seconds)]" };
4343
}
4444
}
4545
}

NebulaWorld/Chat/Commands/SystemCommandHandler.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ public void Execute(ChatWindow window, string[] parameters)
3838
resp = "Could not find given star '" + input + "'";
3939
}
4040

41-
window.SendLocalChatMessage(resp, ChatMessageType.CommandOutputMessage);
41+
window.SendLocalChatMessage(resp, ChatMessageType.CommandErrorMessage);
4242
}
4343
public string GetDescription()
4444
{
4545
return "List planets in a system";
4646
}
47-
public string GetUsage()
47+
public string[] GetUsage()
4848
{
49-
return "[star name]";
49+
return new string[] { "[star name]" };
5050
}
5151
}
5252
}

NebulaWorld/Chat/Commands/WhisperCommandHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ public string GetDescription()
5252
return $"Send direct message to player. Use {ChatCommandRegistry.CommandPrefix}who for valid user names";
5353
}
5454

55-
public string GetUsage()
55+
public string[] GetUsage()
5656
{
57-
return "<player> <message>";
57+
return new string[] { "<player> <message>" };
5858
}
5959

6060
public static void SendWhisperToLocalPlayer(string sender, string mesageBody)

NebulaWorld/Chat/Commands/WhoCommandHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ public string GetDescription()
2929
return "List all players";
3030
}
3131

32-
public string GetUsage()
32+
public string[] GetUsage()
3333
{
34-
return "";
34+
return new string[] { "" };
3535
}
3636

3737
public static string BuildResultPayload(IPlayerData[] allPlayers, ILocalPlayer hostPlayer)

NebulaWorld/Chat/Commands/XConsoleCommandHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ public string GetDescription()
3333
return "Execute developer console command";
3434
}
3535

36-
public string GetUsage()
36+
public string[] GetUsage()
3737
{
38-
return "[XConsole command]";
38+
return new string[] { "[XConsole command]" };
3939
}
4040
}
4141
}

0 commit comments

Comments
 (0)