using System; namespace StardewModdingAPI.Framework { /// Provides an API for managing console commands. internal class CommandHelper : ICommandHelper { /********* ** Accessors *********/ /// The friendly mod name for this instance. private readonly string ModName; /// Manages console commands. private readonly CommandManager CommandManager; /********* ** Public methods *********/ /// Construct an instance. /// The friendly mod name for this instance. /// Manages console commands. public CommandHelper(string modName, CommandManager commandManager) { this.ModName = modName; this.CommandManager = commandManager; } /// Add a console command. /// The command name, which the user must type to trigger it. /// The human-readable documentation shown when the player runs the built-in 'help' command. /// The method to invoke when the command is triggered. This method is passed the command name and arguments submitted by the user. /// The or is null or empty. /// The is not a valid format. /// There's already a command with that name. public ICommandHelper Add(string name, string documentation, Action callback) { this.CommandManager.Add(this.ModName, name, documentation, callback); return this; } /// Trigger a command. /// The command name. /// The command arguments. /// Returns whether a matching command was triggered. public bool Trigger(string name, string[] arguments) { return this.CommandManager.Trigger(name, arguments); } } }