Documentation
¶
Overview ¶
Package kongapp provides a small execution lifecycle for Kong command trees. Applications retain ownership of their command structs, dependencies, config, signal handling, and process exit policy.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Execute ¶
func Execute[T any]( ctx context.Context, args []string, streams Streams, tree *T, cfg Config[T], ) (err error)
Execute parses and runs a consumer-owned Kong command tree. args excludes the process name. The caller owns cancellation, streams, dependency bindings, and conversion of returned errors into process exit statuses.
Types ¶
type Config ¶
type Config[T any] struct { Name string Description string Vars kong.Vars Help kong.HelpOptions DefaultArgs []string Options []kong.Option Initialize Initializer[T] }
Config defines infrastructure policy for one Kong command tree. Application and domain policy stay in the tree, injected options, and Initializer.
type Initializer ¶
type Initializer[T any] func( ctx context.Context, parsed *kong.Context, tree *T, args []string, ) (Cleanup, error)
Initializer runs after successful parsing and before the selected command. The parsed command, populated command tree, and effective arguments are available for application-specific setup. Returning a Cleanup makes teardown part of the same lifecycle even when command execution fails.