using System.Collections.Generic;
namespace SRML.Console.Commands
{
///
/// A command to remove a user defined button from the command menu
///
public class RemoveButtonCommand : ConsoleCommand
{
public override string ID { get; } = "removebutton";
public override string Usage { get; } = "removebutton ";
public override string Description { get; } = "Removes a user defined button from the command menu";
public override string ExtendedDescription => " - The id of the button to remove. 'all' will remove all buttons";
public override bool Execute(string[] args)
{
if (args == null)
{
Console.LogError($"The '{ID}' command takes 1 argument");
return false;
}
if (ArgsOutOfBounds(args.Length, 1, 1))
return false;
if (args[0].Contains(" "))
{
Console.LogError($"The '' argument cannot contain any spaces");
return false;
}
if (!args[0].Equals("all"))
{
if (ConsoleBinder.RemoveBind(args[0]))
{
Console.LogSuccess($"Removed user defined button '{args[0]}'");
return true;
}
}
else
{
ConsoleBinder.RemoveAll();
Console.LogSuccess($"Removed all user defined buttons");
return true;
}
Console.LogError($"The user defined button '{args[0]}' was not found");
return false;
}
public override List GetAutoComplete(int argIndex, string argText)
{
if (argIndex == 0)
return ConsoleBinder.GetAllBinds();
else
return base.GetAutoComplete(argIndex, argText);
}
}
}