Skip to content
Discussion options

You must be logged in to vote

Give a look to this example: https://github.com/janluke/cloup/tree/lazy-loading-example/examples/lazy_loading.

The idea is that rather than extending a MultiCommand, I define proxies (LazyCommand and LazyGroup) for lazy-loaded commands. Then I use those lazy commands as if they were normal commands.

The problem with this approach is that you need to be careful because any attribute/method access on the proxy which cannot be satisfied directly from the proxy itself will cause the command to be loaded. So if you go for this approach, I suggest to put logger.debug("loading module X") on each command module, similarly as I did in the example with print().

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@cbandera
Comment options

@janluke
Comment options

@cbandera
Comment options

Answer selected by cbandera
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants