-
Notifications
You must be signed in to change notification settings - Fork 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
{Core} Disable aladdin recommendation in autocomplete mode #25145
Conversation
Core |
def is_autocomplete(): | ||
"""Detect if the command is running in autocomplete mode""" | ||
from knack.completion import ARGCOMPLETE_ENV_NAME | ||
return os.environ.get(ARGCOMPLETE_ENV_NAME) is not None |
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.
I think we already have similar logic:
self.data['completer_active'] = ARGCOMPLETE_ENV_NAME in os.environ |
if is_autocomplete(): | ||
return True |
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.
This can be retrieved from self.cli_ctx.data['completer_active']
.
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.
Nice catch, I'll update #24765 too.
Description
If the command is not complete, you will get recommendation.
For example, run
az account
you getIn autocomplete mode, it's common that the command is not complete. The recommendation is useless and time-consuming.
So I disable it in autocomplete mode.
Testing Guide
time IFS=$'\013' _ARC_DEBUG=1 COMP_LINE='az account' COMP_POINT=11 COMP_TYPE="" _ARGCOMPLETE=1 _ARGCOMPLETE_SUPPRESS_SPACE=0 az 8>&1 1>&1 2>&1 9>&1
takes 0.4s.After applying this PR, it only takes 0.2s.
This checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.