Add invocation coordination and diagnostics

This commit is contained in:
2026-10-07 13:30:24 +00:00
parent f206c531f1
commit c3448a2ebe
5 changed files with 462 additions and 3 deletions

View File

@@ -99,6 +99,7 @@ type commandPayload interface {
hasRun() bool
bridgeFlags() []internalcobra.Flag
prepare([][]string, []string, bool) (func() any, error)
checkInput(any) error
run(Invocation, any) Outcome
}
@@ -146,6 +147,13 @@ func (c typedCommand[I]) run(invocation Invocation, input any) Outcome {
return c.spec.Run(invocation, *input.(*I))
}
func (c typedCommand[I]) checkInput(input any) error {
if c.spec.CheckInput == nil {
return nil
}
return c.spec.CheckInput(*input.(*I))
}
// NewCommand validates and creates a typed command declaration. It retains
// callbacks without invoking them and copies the declarative flag and argument
// slices.