-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for sharing and stand-alone parsing of subcommands. Warn about parse calls on commands added with .command()
#1938
Conversation
Co-authored-by: John Gee <john@ruru.gen.nz>
Nice clear labelling as "Proof of concept" and "Draft", and good description to explain. The approach of having a stable forward/subcommand link while wiring up the reverse/parent links while parsing is an interesting idea. The wiring itself is indeed "low effort". The downside is a more complex model for maintainers and to a lesser extent authors, to support some exotic reuse configurations. I am comfortable with the current simple model of one stable tree with matching forwards and backwards links. This POC is not something I am interested in proceeding with at this time. |
…mand-parse-warning
Hmm, I expected the already merged commits to not be shown anymore after changing base and merging with the new one. Well, at least the file changes are not cluttered anymore. |
.currentParent is expected to never be different from .parent in existing code using the library as intended.
What kind of authors would the more complex model affect? Authors of libraries extending the functionality of Commander somehow? I don't think any maintenance complications are implied for authors of CLI applications using Commander as currently intended (only adding commands to one parent and parsing from that parent) since the change is fully backwards compatible and invisible in such cases (I have even got rid of
One reason I want to support the exotic reuse configurations is because right now, parsing subcommands as stand-alones is allowed despite being a meaningless operation (since the |
Replaces getCommandAndParents(): - turned into an instance method - used "ancestors" instead of "parents" because it is more specific and to avoid confusion with the recently introduced parents array
.command()
I can agree some overhead is introduced for contributors, but really insignificant. Would just have to think whether iterating over |
A corresponding type test for parents has been added.
.command()
.command()
I would now like this PR and #1940 to supersede #1917. See #1917 (comment) for details. |
Just a quick note. I keep finding myself putting |
This is a useful note, thanks: #1938 (comment) I added one previous warning because of a mistake I kept making: #1655 |
Only call when all elements are to be iterated. Resort to manual iteration via .parent in other cases.
Motivation: tj#1955
…ith-implicit-subcommand-parse-warning
Made it less strict: the library user might know better.
These changes are not something I am interested in proceeding with. |
An extension of #1937 showcasing a better version of the changes I suggested in #1917 (comment).
This was originally a proof of concept PR that expected to give new life to #1917 and #1924.
Now, I would like this PR and #1940 to supersede #1917. See #1917 (comment) for details.
Partially fixes #1916.
ChangeLog
Added
.command()
Motivation
.command()
Implementation details
parent
to the invoking parent command at the beginning of_parseCommand()
parents
to store all parent commands so that no parent checks have to be moved to parse calls, which I wrongly assumed would be necessary in my comment to #1924 (see how_checkForBrokenPassThrough()
is implemented in this PR, for example)_implicitlyCreated
indicating whether the command was created with.command()
.command()
chainPeer PRs
Warnings need to be consistent with…
chainArgParserCalls()
for configuration. Additionally await thenable implicit and default option values and thenable default argument values #1915.parse()
#1940Requires changes when merged with…
.suppressWarnings()
for warnings in #1915 #1931 #1938 #1940 #1955