Allow setting the default command separately from the construction#1422
Allow setting the default command separately from the construction#1422
Conversation
|
First thoughts: looks reasonable. Will be first time we modify behaviour referencing a command by name. I think (This is the second mention in last week of loading commands from directory. That might be getting more common!) |
|
In case I am missing something, I don't think this line in the last example is needed or correct? |
|
You're right about the I also thought so about the Whatever you folks choose is fine by me, and I can refactor the code to fit. :) |
|
I have mixed feelings about this. I do like it slightly better than the existing approach, but we do already have the existing approach! Pros:
Cons:
Would you please open an issue suggesting adding this to see if gets some support as an enhancement? (And assuming does, we can reopen this.) The code is simple, the naming and implications are the hard part! Playing with routine names. |
|
For interest, I looked for naming in other packages. |
|
A wildcard would introduce more complexity as we would have to implement a priority mechanism, only looking for wildcards when the exact name is not a match. I would also argue that having a dedicated function (either on the child or the parent command) would make it clearer for a reader and more discoverable, due to autocomplete support. |
|
I saw setting default command separately mentioned in a by-the-way in another PR: #1186 (comment) |
In a project I'm working on, the commands are added dynamically, like so:
This makes pretty hard (or at least harder than it should be) to set the default command, as I would have to mess with the loading, mixing concerns.
This pull request implements the following interface:
To me, it looks more natural, since I think this configuration belongs on the parent command, not the command itself, as it is even coded like that internally.