-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Fix combining wt args and "wt new-tab" args in implicit context #8315
Fix combining wt args and "wt new-tab" args in implicit context #8315
Conversation
…ions before the implicit tab command
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh well that was easy 😅 I didn't know about prefix_command
, thanks for finding this!
// we still have unparsed parameters we need to fail | ||
if (remainingParams > 0) | ||
{ | ||
throw CLI::ExtrasError(args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
who catches this? Does it end up down on line 92 as a ParseError?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. It is caught there as a parse error. Implemented this to allow future handling. I can handle it immediately if you prefer.
} | ||
} | ||
catch (const CLI::CallForHelp& e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we losing support for CallForHelp?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my understanding the CallForHelp was here only to prevent implicit subcommand parsing (the second catch clause). Now we don't have this catch clause, thus we can handle all exceptions the same way by calling _handleExit, that will still show the relevant UI.
Don't mind me editing your bodies and titles -- I like to maintain imperative mood and some line wrapping rules, but I don't want to force the community to do that 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't mind me editing your bodies and titles -- I like to maintain imperative mood and some line wrapping rules, but I don't want to force the community to do that 😄
Sure! Actually, I didn't like the title in the first place - lately I simply copy the title of the issue to the PR... not sure it is a good approach 😊
// we still have unparsed parameters we need to fail | ||
if (remainingParams > 0) | ||
{ | ||
throw CLI::ExtrasError(args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. It is caught there as a parse error. Implemented this to allow future handling. I can handle it immediately if you prefer.
} | ||
} | ||
catch (const CLI::CallForHelp& e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my understanding the CallForHelp was here only to prevent implicit subcommand parsing (the second catch clause). Now we don't have this catch clause, thus we can handle all exceptions the same way by calling _handleExit, that will still show the relevant UI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With my questions answered, I'll sign off. This is great. 😄
So, with regards to copying the issue being the right approach for a title... I like to follow this guide on "good commit messages". It's obviously a personal style or opinion 😄 but it helps me out. I use the same rules for PR bodies as commits because we use the PR title as the commit and the PR body as the body. The basic rules I follow:
I like to delete the HTML comments I should get a request out on the msftbot people to remove HTML comments themselves! Otherwise it just clutters up the commit body when it DOES get merged. |
I like those guidelines and will try to follow them! |
Currently when implicit tab command is specified (i.e., we have parameters for new-tab, but don't have the explicit subcommand name) we fallback to parsing the entire arg list as new tab command. However, if we also have a launch profile (or anything else that might in the future belong to the upper scope) it is passed as a parameter to the new tab command, failing the parsing. The idea behind my solution is to run the parser as a prefix command - i.e., as long as we succeed to parse [options] / [subcommand] we will parse them (populating the fields like a launch mode), but once we will discover something unfamiliar, like profile, we will know that the prefix is over and will handle the remaining suffix as a new tab command. ## Validation Steps Performed * UT added * Manual run of different options Closes #7318 (cherry picked from commit 435e457)
🎉 Handy links: |
🎉 Handy links: |
Currently when implicit tab command is specified (i.e., we have
parameters for new-tab, but don't have the explicit subcommand name) we
fallback to parsing the entire arg list as new tab command.
However, if we also have a launch profile (or anything else that might in
the future belong to the upper scope) it is passed as a parameter to the
new tab command, failing the parsing.
The idea behind my solution is to run the parser as a prefix command -
i.e., as long as we succeed to parse [options] / [subcommand] we will
parse them (populating the fields like a launch mode), but once we will
discover something unfamiliar, like profile, we will know that the
prefix is over and will handle the remaining suffix as a new tab
command.
PR Checklist
Validation Steps Performed
Closes #7318