public sealed class ConsoleCommandsThe commands a console can run, and the lines they have written back.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Separate from ConsoleOverlay because the two are useful apart: a remote inspector runs commands with no overlay drawn, and a test runs them with no screen at all. The overlay is one front end onto this.
⚠ A command runs on whatever thread called Execute. Nothing here marshals. The overlay calls it from the loop thread, which is where a command that touches the world has to be; a remote inspector must queue rather than call straight off its socket thread.
Fields and properties (5)
public const int MaxOutputHow many output lines are kept.
public const int MaxHistoryHow many entered lines are remembered.
public IReadOnlyCollection<ConsoleCommand> RegisteredEverything registered, in no particular order.
public IReadOnlyList<string> OutputThe lines commands have written, oldest first.
public IReadOnlyList<string> HistoryThe lines that have been entered, oldest first.
Methods (9)
public ConsoleCommands()Builds a registry with the built-in commands in it.
public void Register(string name, string help, Action<ConsoleContext> run)Adds a command.
public bool Remove(string name)Removes a command.
public int Complete(ReadOnlySpan<char> prefix, List<string> matches)Finds the commands whose names start with a prefix, for completion.
public bool Execute(string line)Runs a line.
public void Write(string text)Writes a line of output.
public void Clear()Throws the output away. Does not touch the history.
public int RegisterFrom(Assembly assembly)Finds every ConsoleCommandAttribute-marked static method in an assembly and registers it.
public int RegisterFrom(Type type)Registers the marked static methods of one type.
Used by (4)
- ConsoleContextVixen.Engine
- ConsoleOverlayVixen.Engine
- ConsoleTestsVixen.Engine.Tests
- DiagnosticOverlaysVixen.Engine