Add invocation coordination and diagnostics
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user