Repository navigation
Autocomplete
Tab completes command names, then argument values. bool and enum parameters complete with zero setup.
public static void GiveCommand(CommandResponseDelegate reply,
[Suggest(typeof(Players), nameof(Players.Suggest))] string target,
[SuggestValues("Sword", "Shield")] string item)| Attribute | Use |
|---|---|
[SuggestValues("a", "b")] |
Fixed list, any parameter type. |
[Suggest(nameof(MyMethod))] |
Same-class static method: () or (AutoCompleteContext). |
[Suggest(typeof(Shared), nameof(Shared.Method))] |
Shared across classes. |
Providers return candidates; UniTerminal filters and sorts them. AutoCompleteContext carries Prefix, ArgIndex (as typed — response callback skipped), ParamName, TypedArgs.
Fixed list — works on any parameter type, even int:
[ConsoleCommand("coins", Description = "Grants coins.")]
public static void CoinsCommand(CommandResponseDelegate response,
[SuggestValues("50", "250", "1000", "5000")] int amount = 250)Same-class provider — static method returning candidates:
[ConsoleCommand("spawn", Description = "Spawns an entity.")]
public static void SpawnCommand([Suggest(nameof(GetEntityNames))] string entityName)
{ ... }
private static IEnumerable<string> GetEntityNames()
{
return new[] { "Slime", "Goblin", "Dragon" };
}Shared provider — one source reused across commands:
public static void GiveCommand(CommandResponseDelegate reply,
[Suggest(typeof(Players), nameof(Players.Suggest))] string target)
{ ... }
static class Players
{
public static IEnumerable<string> Suggest(AutoCompleteContext ctx) => AllPlayers;
}Attributes can't hold function references, so anything else — lambdas closing over live game data, method groups, existing static methods — is registered at startup instead:
UniTerminal.RegisterSuggestions<FoodId>(ctx => FoodDb.AllNames); // every FoodId param
UniTerminal.RegisterSuggestions("give", "item", ctx => ItemDb.FindMatches(ctx.Prefix)); // one paramResolution order: attributes → registered providers → bool/enum built-ins.
UniTerminal.RegisterSuggestions<EnemyPoolId>(SuggestPools); // method group
UniTerminal.RegisterSuggestions("spawn", "count", _ => new[] { "1", "3", "5", "10" }); // fixed set without an attribute
static IEnumerable<string> SuggestPools(AutoCompleteContext ctx) => EnemyPools.AllNames;The context carries everything a provider might need — filter by typed prefix, branch per argument, or look at sibling args:
UniTerminal.RegisterSuggestions("craft", "recipe", ctx =>
RecipeDb.ForLevel(Player.level).Where(r => r.StartsWith(ctx.Prefix)));AutoCompleteProvider = nameof(Method) on [ConsoleCommand] still works (one provider per command, you filter string variants yourself), but migrate to per-parameter attributes when you touch those commands.