/// <summary> /// Generates help info for the given cog. /// </summary> /// <param name="prog">The program from which the help command is being run.</param> /// <param name="cog">The cog for which to generate the help info.</param> /// <returns>A string containing the help information.</returns> /// <seealso cref="Help()" /> /// <seealso cref="Help(Commander.Program,Commander.CommandObj)" /> public string Help(Program program, Cog cog) { /* * [Cog Name] * Description: * <description> * * Commands: * <commands> */ var cogName = program.IsCaseSensitive ? cog.Name : cog.Name.ToLower(); var info = new StringBuilder(); info.Append('[').Append(cogName).Append("]\nDescription:\n").Append(cog.Description); if (cog.Commands.Count > 0) { info.Append("\n\nCommands:\n"); foreach (var cmd in cog.Commands.Values) { info.Append(cmd.Name).Append('\n'); } // remove trailing \n char info.Remove(info.Length - 1, 1); } return(info.ToString()); }
/// <summary> /// Removes the given cog from the program. /// </summary> /// <param name="cog">The cog to remove from the program.</param> public void Deregister(Cog cog) { var name = IsCaseSensitive ? cog.Name : cog.Name.ToLower(); if (!_cogs.ContainsKey(name)) { return; } _cogs.Remove(name); Utils.Debug($"removed cog: {name}"); }
/// <summary> /// Adds the given cog to the program. /// </summary> /// <param name="cog">The cog to register in the program.</param> public void Register(Cog cog) { var name = IsCaseSensitive ? cog.Name : cog.Name.ToLower(); if (_cogs.ContainsKey(name)) { return; } _cogs.Add(name, cog); Utils.Debug($"added cog: {name}"); }