You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extracted from work on an internal tool at Icelolly, this would be useful for larger applications with sprawling dependencies.
// We could make a function for adding factories for commands, to enable lazy-loading of commands,
// meaning their dependencies wouldn't be created if they weren't going to be used. Added like:
//
// app.AddCommandFactory("apply", resolver.ResolveApplyCommand)
//
// On the resolver, we'd have our factory function.
//
// func (r *Resolver) ResolveApplyCommand() *console.Command {
// // ...
// }
//
// For sub-commands, we'd need to just do the same, but the factory functions would be passed as
// dependencies in the resolver. Something like:
//
// func (r *Resolver) ResolveContainerCommand() *console.Command {
// return container.NewCommand(
// r.ResolveContainerListCommand,
// r.ResolveContainerInspectCommand,
// // ...
// )
// }
//
// Note that the factory function itself is passed in, the resolver is not being invoked at this
// point. This stops us from passing the resolver around, meaning that testing should still be easy
// enough to accomplish. We could just replace the sub-commands in tests with a no-op factory.
The text was updated successfully, but these errors were encountered:
Extracted from work on an internal tool at Icelolly, this would be useful for larger applications with sprawling dependencies.
The text was updated successfully, but these errors were encountered: