mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
feat: get command description with /xlhelp
This commit is contained in:
parent
a7ff558ed7
commit
85798cc11a
1 changed files with 16 additions and 8 deletions
|
|
@ -32,7 +32,7 @@ internal class DalamudCommands : IServiceType
|
|||
|
||||
commandManager.AddHandler("/xlhelp", new CommandInfo(this.OnHelpCommand)
|
||||
{
|
||||
HelpMessage = Loc.Localize("DalamudCmdInfoHelp", "Shows list of commands available."),
|
||||
HelpMessage = Loc.Localize("DalamudCmdInfoHelp", "Shows list of commands available. If an argument is provided, shows help for that command."),
|
||||
});
|
||||
|
||||
commandManager.AddHandler("/xlmute", new CommandInfo(this.OnBadWordsAddCommand)
|
||||
|
|
@ -147,15 +147,23 @@ internal class DalamudCommands : IServiceType
|
|||
var chatGui = Service<ChatGui>.Get();
|
||||
var commandManager = Service<CommandManager>.Get();
|
||||
|
||||
var showDebug = arguments.Contains("debug");
|
||||
|
||||
chatGui.Print(Loc.Localize("DalamudCmdHelpAvailable", "Available commands:"));
|
||||
foreach (var cmd in commandManager.Commands)
|
||||
if (arguments.IsNullOrWhitespace())
|
||||
{
|
||||
if (!cmd.Value.ShowInHelp && !showDebug)
|
||||
continue;
|
||||
chatGui.Print(Loc.Localize("DalamudCmdHelpAvailable", "Available commands:"));
|
||||
foreach (var cmd in commandManager.Commands)
|
||||
{
|
||||
if (!cmd.Value.ShowInHelp)
|
||||
continue;
|
||||
|
||||
chatGui.Print($"{cmd.Key}: {cmd.Value.HelpMessage}");
|
||||
chatGui.Print($"{cmd.Key}: {cmd.Value.HelpMessage}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var targetCommandText = arguments[0] == '/' ? arguments : $"/{arguments}";
|
||||
chatGui.Print(commandManager.Commands.TryGetValue(targetCommandText, out var targetCommand)
|
||||
? $"{targetCommandText}: {targetCommand.HelpMessage}"
|
||||
: Loc.Localize("DalamudCmdHelpNotFound", "Command not found."));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue