BadScript 2
Loading...
Searching...
No Matches
BadDefaultNetworkClientCommandParser.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Linq;
4
6
11
16{
21
25 private readonly List<BadNetworkConsoleClientCommand> m_Commands = new List<BadNetworkConsoleClientCommand>();
26
35
39 public IEnumerable<BadNetworkConsoleClientCommand> Commands => m_Commands;
40
41
43 public void ExecuteCommand(string command)
44 {
45 string[] parts = command.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
46
47 if (parts.Length == 0)
48 {
49 return;
50 }
51
52 string name = parts[0];
54 {
55 if (cmd.Name == name)
56 {
57 cmd.Invoke(parts.Skip(1).ToArray());
58
59 return;
60 }
61 }
62
63 BadConsole.WriteLine("Unknown Command: " + name);
64 }
65
70 public void AddCommand(Func<BadNetworkConsoleClient, BadNetworkConsoleClientCommand> command)
71 {
72 m_Commands.Add(command(m_Client));
73 }
74}
Wrapper class for the console abstraction.
Definition BadConsole.cs:12
static void WriteLine(string str)
Writes a string to the console and appends a newline.
Definition BadConsole.cs:76
void AddCommand(Func< BadNetworkConsoleClient, BadNetworkConsoleClientCommand > command)
Adds a Command to the Command List.
void Invoke(string[] args)
Executes the Command with the given arguments.
Contains the Console Client Implementation for the Remote Console Abstraction over TCP.