Repository navigation
Conversation
🦋 Changeset detectedLatest commit: 81e709a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
|
Did you see my comment? I think the existing implementation matches Commander default behaviour, root options mask subcommand options. #153 (comment) However, I am not too worried if you do go ahead and change behaviour:
|
Hey John! // root: -c, --config <file> (takes a value)
// serve: -c, --color (boolean)
// serve: [env] (positional)commander: $ app serve -c root.jsontab: $ app complete -- serve -c ''
:4tab first uses the root --config option to decide that -c needs a value, but then uses the matched command's boolean --color option to find the completion handler. It therefore returns nothing. commander: root.json
Active command behavior: prod [env for serve subcommand]
tab behavior: nothingits like a mixture of both lookup policies rather than a complete implementation of either. I should revise this PR and the solution, I'd be happy hearing any feedback/suggestions from you. |
|
Thanks for reply and explanation! I'll try and take a bit of a dive into the bombshell parsing, and experiment, so I can make more informed comments. |
|
Slightly different reproduction, again confirming old implementation does not match Commander default masking anyway. This is just testing which completion handler and not arity. Using shipping % my-masking complete -- -c ''
top
global
:4
% my-masking complete -- serve -c ''
leaf
local
:4
% my-masking serve -c leaf
error: option '-c, --gc <number>' argument 'leaf' is invalid. Allowed choices are top, global. |
|
I did an end-to-end test with Commander to somewhat match reproduction in #153. Turned on Commander % node repro-153.mjs complete -- -H ''
:4
% node repro-153.mjs complete -- serve -H ''
localhost
:4
% node repro-153.mjs complete -- serve ''
prod
staging
:4
% node repro-153.mjs serve -H localhost prod
Starting server with host localhost and env prod |
|
Surveying runtimes looking at three questions:
(Apologies in advance for any parsers I have misunderstood! I wrote example programs for each and consulted their documentation for how to configure the program.) |
| const option = this.findOption(matchedCommand ?? this, arg); | ||
| const isBoolean = option?.isBoolean ?? false; |
There was a problem hiding this comment.
If the option is not on matched command, I think you need to fallback and check the root command too?
Or more generally if deep command hierarchies are supported, need too check against commands from the leaf to the root (assuming nearest command wins).
|
High level summary of my various comments:
I started going carefully through the PR and found one potential parsing problem. I stopped at that point partly because taking a break, partly because code might change in response. |
closes #153