Skip to content

Conversation

@fengzhou-msft
Copy link
Member

Description

Previously we only match users' input command with a complete command (not including options), so command like az blueprint -h will not be matched with an extension command and dynamic install of the extension will not be triggered.

This PR adds support for command prefix match so that commands like az blueprint, az blueprint -h will also trigger the dynamic install of the blueprint extension. It also handle cases when the command matches the prefix of multiple extensions. It will prompt to let users select an extension to install.

This PR also fixes the false positive of misspelled commands by checking extension command match first. Previously, if a candidate of close match to core module command is found, the command is considered to be misspelled. It increased the preformance but have some false positves.

Testing Guide

  1. Run az blueprint -h and CLI will prompt:

The command requires the extension blueprint. Do you want to install it now? The command will continue to run after the extension is installed. (Y/n):

  1. We don't have cases that will trigger the selection of multiple extensions, you can mock up by adding {"fake-cmd": "fake-ext"} to some extension in the ~/.azure/extensionCommandTree.json (or in your env/.azure/extensionCommandTree.json),for instance under vm aem. Then run az vm aem -h, the output would be:

The command requires the latest version of one of the following extensions. You need to pick one to install:
[1] aem
[2] fake-ext
Please enter a choice [Default choice(1)]: 1
The command requires the extension aem. It will be installed first.
- Installing ..
...

  1. For misspelled case, azcopy was considered as a typo for copy which is in the main module command. With this PR if you run az storage azcopy blob delete -c test1 -t a.txt --account-name mydefault, it should prompt you to install storage-preview.

History Notes

[Component Name 1] BREAKING CHANGE: az command a: Make some customer-facing breaking change.
[Component Name 2] az command b: Add some customer-facing feature.


This checklist is used to make sure that common guidelines for a pull request are followed.

@yonzhan
Copy link
Collaborator

yonzhan commented Dec 14, 2020

@jiasli for awareness

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants