From 029932910dd8de00a1f20f2dc4d45b2fe474f33a Mon Sep 17 00:00:00 2001 From: Harrison Date: Mon, 24 Feb 2020 02:59:15 -0500 Subject: [PATCH] Added parameter check to EngineCommand.cs makes sure all invoke strings don't contain spaces. Scope change makes sure to not break parameter rules. --- RecrownedGTK.Tools/CommandProcessor/EngineCommand.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/RecrownedGTK.Tools/CommandProcessor/EngineCommand.cs b/RecrownedGTK.Tools/CommandProcessor/EngineCommand.cs index a010363..bf58120 100644 --- a/RecrownedGTK.Tools/CommandProcessor/EngineCommand.cs +++ b/RecrownedGTK.Tools/CommandProcessor/EngineCommand.cs @@ -12,7 +12,7 @@ namespace RecrownedGTK.Tools.CommandProcessor /// /// the words a user can type that will invoke this command. /// - protected string[] invokeStrings; + private string[] invokeStrings; public string[] InvokeStrings { get { return invokeStrings; } } /// @@ -24,6 +24,11 @@ namespace RecrownedGTK.Tools.CommandProcessor public EngineCommand(params string[] invokeStrings) { this.invokeStrings = invokeStrings ?? throw new ArgumentNullException(); + for (int i = 0; i < invokeStrings.Length; i++) { + if (invokeStrings[i].Contains(" ")) { + throw new ArgumentException("Can't have spaces in command invocation strings."); + } + } } /// @@ -51,8 +56,8 @@ namespace RecrownedGTK.Tools.CommandProcessor /// /// Runs the command. /// - /// arguments to be used. May be null. - public abstract void Run(IUserInput userInput = null, IUserOutput userOutput = null, string[] arguments = null); + /// arguments to be used. Each string should be the argument input. May be null. + public abstract void Run(IUserInput userInput = null, IUserOutput userOutput = null, params string[] arguments); /// /// Check if given argument is viable for command.