Repository navigation
Conversation
commit: |
|
|
A one-time behavioral probe could also work i think. |
Do you mean to avoid accessing the private I'll think about how to expose this state, but it will of course only be usable in new versions. There isn't a strong reason for having this state/property private. (I tend to make new properties private until there is a demand for them, to simplify internal changes and keep the API smaller.) |
|
Thanks for working on this! Would you like a review? |
Yes, please!🙌🏼 |
|
Working my way slowly through the new code. Is the goal for now to leave the old code largely untouched and behaviour unchanged unless
|
|
|
||
| export type OptionLookupMode = 'parent-first' | 'local'; | ||
|
|
||
| const optionLookupModes = new WeakMap<RootCommand, OptionLookupMode>(); |
There was a problem hiding this comment.
The code is using this WeakMap to lookup a value being held separate from the RootCommand. Is there a reason for that, rather than just having a property on the RootCommand? (It isn't wrong but I am wondering if this pattern means I didn't understand something, or might be a left-over from an early approach when it was needed.)
(In Commander technically the lookup mode can be set on any command in hierarchy and not just the RootCommand, but in practice usually set the same on all commands. I am fine with only being set on RootCommand.)
There was a problem hiding this comment.
The code is using this WeakMap to lookup a value being held separate from the RootCommand. Is there a reason for that, rather than just having a property on the RootCommand? (It isn't wrong but I am wondering if this pattern means I didn't understand something, or might be a left-over from an early approach when it was needed.)
(In Commander technically the lookup mode can be set on any command in hierarchy and not just the RootCommand, but in practice usually set the same on all commands. I am fine with only being set on RootCommand.)
Good point... I initially used the WeakMap to keep adapter-specific lookup state separate from RootCommand and avoid exposing another property. But I guess there is no real benefit here. I moved it onto RootCommand
|
I have carefully read through the new code and makes sense. I like I'll work through the tests and do some runtime manual tests too to confirm coverage. I was just taking a light look at the fixture and can see some thoughtful layers of options for probes! |
|
(Full disclosure. I am wondering about having a go at making Commander parse options with local-first priority by default in a future major version. Prompted in part by the discussions and investigations here! Not a high priority though and may turn out to be too hard.) |
|
Unit tests and manual checks of behaviour look good. |
|
I have been AFK and just went through your review and suggestions, thanks a lot! that is really helpful. ❤️
Yes, the intention is to preserve the existing behavior unless an adapter configures I applied your suggestions, lmk if something is missing. |
related to the discussions in #154