Added parameter check to EngineCommand.cs
makes sure all invoke strings don't contain spaces. Scope change makes sure to not break parameter rules.
This commit is contained in:
parent
92f302875f
commit
029932910d
@ -12,7 +12,7 @@ namespace RecrownedGTK.Tools.CommandProcessor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// the words a user can type that will invoke this command.
|
/// the words a user can type that will invoke this command.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected string[] invokeStrings;
|
private string[] invokeStrings;
|
||||||
public string[] InvokeStrings { get { return invokeStrings; } }
|
public string[] InvokeStrings { get { return invokeStrings; } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -24,6 +24,11 @@ namespace RecrownedGTK.Tools.CommandProcessor
|
|||||||
public EngineCommand(params string[] invokeStrings)
|
public EngineCommand(params string[] invokeStrings)
|
||||||
{
|
{
|
||||||
this.invokeStrings = invokeStrings ?? throw new ArgumentNullException();
|
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.");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -51,8 +56,8 @@ namespace RecrownedGTK.Tools.CommandProcessor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Runs the command.
|
/// Runs the command.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="arguments">arguments to be used. May be null.</param>
|
/// <param name="arguments">arguments to be used. Each string should be the argument input. May be null.</param>
|
||||||
public abstract void Run(IUserInput userInput = null, IUserOutput userOutput = null, string[] arguments = null);
|
public abstract void Run(IUserInput userInput = null, IUserOutput userOutput = null, params string[] arguments);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check if given argument is viable for command.
|
/// Check if given argument is viable for command.
|
||||||
|
Loading…
Reference in New Issue
Block a user