Aliases, groups and docs

Short forms of your commands, groups to organize them, and their help.

Aliases

[CommandAlias("alias", "full command")] gives a command a shorter entry, or a fully specified one that needs no argument at all. Put it next to [Command], as many times as you need:

[Command("timescale")]
[CommandAlias("pause", "timescale 0")]
[CommandAlias("resume", "timescale 1")]
[CommandAlias("slowmo", "timescale 0.25")]
static void SetTimeScale(float scale) => Time.timeScale = scale;
  • The full command starts with the name of the command (after its target, for a command that runs on objects: @Player heal 100).
  • What you type after an alias is added at the end: log "hello" runs echo -v log "hello".
  • An alias that doesn't give every required parameter still asks for the missing ones. One that gives them all has a button in the Commands tab.
  • A parameter the alias already gives can't be given again: warning "hi" -v error fails.
  • An alias whose name is taken by a command or another alias is skipped, with a warning in Unity's Console.

Groups

[CommandGroup] puts a command in a group. list shows the commands group by group, and the Commands tab has a tab per group. A group is a path: every / starts a subgroup.

[Command("god-mode")]
[CommandGroup("Game/Cheats")]
static void GodMode() { }

[Command("give-gold")]
[CommandGroup("Game/Economy")]
static void GiveGold(int amount) { }
  • A command without a group is in the group default.
  • An alias is in the group of its command.
  • Spaces around a / and empty parts don't count: " Game / /Cheats " is Game/Cheats. Case does: game and Game are two groups.
  • The console's own commands are in Console, those of the samples in Unity/... (Generic Unity commands) and Space Shooter.

Documenting your commands

  • [CommandSummary("...")] on the method: a short description, shown by list and help. A command without one shows TBD.
  • [ParamInfo("...")] on a parameter: what it expects, shown by help.
[Command("echo")]
[CommandSummary("Display a message in the console")]
static void Echo(
    [ParamInfo("The message to display")] string message,
    [Shortcut('v'), ParamInfo("log, warning or error")] VerboseLevel verbose = VerboseLevel.Log)
{ /* ... */ }

list and help

> list -f spawn
> list -g Game
> list --alias
> help pause
  • list shows every command, group by group (default first, then by name), with its summary. -f text keeps the commands whose name contains the text; -g Game the commands of Game and of its subgroups (Game/Cheats...), whatever its case; --alias also lists the aliases and what they stand for.
  • help shows the syntax, the summary and the parameters of a command; for an alias, what it stands for, then the help of its command.
  • Both mark a protected command with Protected, and a command that runs on objects with an italic @.
list --alias: the commands and aliases, group by group.
list --alias: the commands and aliases, group by group.