using System;
namespace StardewModdingAPI.Framework.ModHelpers
{
/// Provides an API for managing console commands.
internal class CommandHelper : BaseHelper, ICommandHelper
{
/*********
** Fields
*********/
/// The mod using this instance.
private readonly IModMetadata Mod;
/// Manages console commands.
private readonly CommandManager CommandManager;
/*********
** Public methods
*********/
/// Construct an instance.
/// The mod using this instance.
/// Manages console commands.
public CommandHelper(IModMetadata mod, CommandManager commandManager)
: base(mod?.Manifest?.UniqueID ?? "SMAPI")
{
this.Mod = mod;
this.CommandManager = commandManager;
}
///
public ICommandHelper Add(string name, string documentation, Action callback)
{
this.CommandManager.Add(this.Mod, name, documentation, callback);
return this;
}
///
public bool Trigger(string name, string[] arguments)
{
return this.CommandManager.Trigger(name, arguments);
}
}
}