Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Configure is called for all commands when potentially/arguably only the description is needed. #21781
If you have several
This is normally fine and I suspect this presents little or no problems at all.
But, as a consequence, when only the command's description is required (when running the application without any command) or no configuration required at all (when running the application with another command), the entire command is configured every single time. If that configuration requires access to external sources to provide options, or default values, etc. then this happens unnecessarily. Added to that, if there is an error in this external data retrieval, the exception is generated for what seems a completely unrelated command.
It would be nice to be able to be a bit more circumspect with what code is executed.
From that, I think there are 3 types of usage:
One area where I'm not sure of is the interaction between command A running command B. I'm thinking this should match type 3 above.
If this is an issue for anyone, then I'm happy to work on it and build a PR, but would appreciate some direction on a good implementation. Ideally not too intrusive and something that is backward compatible.
FYI: There have been many, many, different, failed, attempts at resolving the issues you listed and others in the past. Good luck, though: I think most people would agree the command component needs some TLC. The five aforementioned PRs and issues linked may give you some inspiration, as well as context as to what directions not to take, at the very least.
Hmm. I see. I hadn't considered the lazyloading/DI context. From my dumb perspective, injecting the application into the command during construction, rather than setting the application on the command once it is instantiated and having the state of the application known (registering commands, requesting command descriptions, executing a command) would seem to fulfil my requirement.
If such an approach was deemed valid, I could present a PR on this.