feat: allow use of providers that don't return errors

This commit is contained in:
Alec Thomas
2025-01-30 13:39:31 +11:00
parent 9c08a58eb2
commit 4e1757c0e8
3 changed files with 35 additions and 3 deletions
+3
View File
@@ -119,6 +119,9 @@ func (c *Context) BindTo(impl, iface any) {
//
// This is useful when the Run() function of different commands require different values that may
// not all be initialisable from the main() function.
//
// "provider" must be a function with the signature func(...) (T, error) or func(...) T, where
// ... will be recursively injected with bound values.
func (c *Context) BindToProvider(provider any) error {
return c.bindings.addProvider(provider)
}