summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/Command.cs
blob: 8c9df47d39c7056df6b1d8a761762a57ccf3c785 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;

namespace StardewModdingAPI.Framework
{
    /// <summary>A command that can be submitted through the SMAPI console to interact with SMAPI.</summary>
    internal class Command
    {
        /*********
        ** Accessor
        *********/
        /// <summary>The mod that registered the command (or <c>null</c> if registered by SMAPI).</summary>
        public IModMetadata Mod { get; }

        /// <summary>The command name, which the user must type to trigger it.</summary>
        public string Name { get; }

        /// <summary>The human-readable documentation shown when the player runs the built-in 'help' command.</summary>
        public string Documentation { get; }

        /// <summary>The method to invoke when the command is triggered. This method is passed the command name and arguments submitted by the user.</summary>
        public Action<string, string[]> Callback { get; }


        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="mod">The mod that registered the command (or <c>null</c> if registered by SMAPI).</param>
        /// <param name="name">The command name, which the user must type to trigger it.</param>
        /// <param name="documentation">The human-readable documentation shown when the player runs the built-in 'help' command.</param>
        /// <param name="callback">The method to invoke when the command is triggered. This method is passed the command name and arguments submitted by the user.</param>
        public Command(IModMetadata mod, string name, string documentation, Action<string, string[]> callback)
        {
            this.Mod = mod;
            this.Name = name;
            this.Documentation = documentation;
            this.Callback = callback;
        }
    }
}