Render help through command aliases

This commit is contained in:
2026-10-19 19:40:55 +00:00
parent 451a0c483f
commit a504efbad7
10 changed files with 391 additions and 11 deletions

View File

@@ -5,6 +5,7 @@ import (
internalcobra "gitea.maximumdirect.net/eric/CommandKit/internal/cobra"
commandmeta "gitea.maximumdirect.net/eric/CommandKit/internal/commandmeta"
"gitea.maximumdirect.net/eric/CommandKit/internal/commandpath"
)
func (a *App) parse(args []string, options commandmeta.ParseOptions) commandmeta.Result {
@@ -34,6 +35,18 @@ func (a *App) buildRoutingSnapshot() *routingSnapshot {
flagAliases: a.flagAliases,
discoveryFlags: a.discoveryFlags,
}
for _, rule := range a.routingRules {
if rule.record.kind != commandAliasRule {
continue
}
snapshot.commandAliases = append(snapshot.commandAliases, commandmeta.CommandAlias{
Source: []string(rule.record.sourcePath.Clone()),
Target: []string(snapshot.aliases.Resolve(rule.record.targetPath)),
})
}
sort.Slice(snapshot.commandAliases, func(i, j int) bool {
return commandpath.FromTokens(snapshot.commandAliases[i].Source).Key() < commandpath.FromTokens(snapshot.commandAliases[j].Source).Key()
})
names := make([]string, 0, len(a.commands))
for name := range a.commands {
names = append(names, name)