Complete CommandKit consumer documentation

This commit is contained in:
2026-10-07 14:56:13 +00:00
parent 0af44a1172
commit 85f44cd358
17 changed files with 587 additions and 76 deletions

View File

@@ -116,7 +116,8 @@ type configInput[C any] struct {
selectors []selectorState[C]
}
// RegisterConfig installs the config family and its scope discovery command.
// RegisterConfig installs the available config handlers and the scope discovery
// command. Its registration and discovery paths do not invoke scope loaders.
func RegisterConfig[C any](app *App, suite ConfigSuite[C]) error {
if app == nil {
return fmt.Errorf("cannot register configuration on a nil app")
@@ -182,7 +183,11 @@ func RegisterConfig[C any](app *App, suite ConfigSuite[C]) error {
return nil
}
// NewConfigKitScope adapts a ConfigKit loader into a configuration scope.
// NewConfigKitScope adapts a ConfigKit loader into a scope with validation,
// effective display, source listing, and path explanation capabilities. The
// loader runs once per selected operation. Successful loads expose the result's
// public facets directly; ConfigKit LoadError records become CommandKit
// diagnostics while the original error is returned.
func NewConfigKitScope[C, T any](name, summary string, load func(context.Context, Selection, C) (*configkit.Result[T], error)) (ConfigScope[C], error) {
if load == nil {
return ConfigScope[C]{}, fmt.Errorf("ConfigKit scope loader must not be nil")