Capture immutable command declarations

This commit is contained in:
2026-10-11 01:15:13 +00:00
parent 476e98a463
commit de9bfdcc4c
16 changed files with 368 additions and 474 deletions

View File

@@ -30,7 +30,7 @@ type versionDocument struct {
}
func (a *App) installBuiltins() error {
help, err := NewCommand(CommandSpec[helpInput]{
help := NewCommand(CommandSpec[helpInput]{
Name: "help",
Summary: "Show help for commands.",
Description: "Describe registered commands and their inputs.",
@@ -41,12 +41,9 @@ func (a *App) installBuiltins() error {
return a.renderHelpTargets(input.Targets.Value, invocation.Streams)
},
})
if err != nil {
return fmt.Errorf("create built-in help command: %w", err)
}
scopeDefault := "app"
formatDefault := "text"
version, err := NewCommand(CommandSpec[versionInput]{
version := NewCommand(CommandSpec[versionInput]{
Name: "version",
Summary: "Show application or CommandKit version.",
Description: "Report identity and build metadata without loading application configuration.",
@@ -65,9 +62,6 @@ func (a *App) installBuiltins() error {
return renderVersionOutcome(identity, input.Format, invocation.Streams)
},
})
if err != nil {
return fmt.Errorf("create built-in version command: %w", err)
}
a.commands["help"] = &commandNode{command: help, reserved: true}
a.commands["version"] = &commandNode{command: version, reserved: true}
return nil