Compile typed command runners

This commit is contained in:
2026-10-11 01:21:52 +00:00
parent 4e0611bc13
commit 74f6bdeade
5 changed files with 69 additions and 42 deletions

View File

@@ -60,6 +60,25 @@ func TestExecuteRunsTypedCommandsWithFreshInvocationState(t *testing.T) {
}
}
func TestOmittedInputFactoryUsesExactPointerZeroValue(t *testing.T) {
command := commandkit.NewCommand(commandkit.CommandSpec[*int]{
Name: "run",
Run: func(_ commandkit.Invocation, value *int) commandkit.Outcome {
if value != nil {
return commandkit.Failure(errors.New("omitted input factory allocated a pointer"))
}
return commandkit.Success()
},
})
app, err := commandkit.New(commandkit.Identity{Name: "example"}, command)
if err != nil {
t.Fatal(err)
}
if outcome := app.Execute(context.Background(), []string{"run"}, commandkit.Streams{}); outcome.Kind != commandkit.OutcomeSuccess {
t.Fatalf("pointer zero value outcome = %#v", outcome)
}
}
func TestExecuteUsesFreshSessionForHelpAfterFlagBearingInvocation(t *testing.T) {
type input struct {
name commandkit.Supplied[string]