Skip to content

Commit 997b231

Browse files
authored
Provide suggestions when command not found (#18984)
* register command not found handler * can search from file * new schema for command mapping file * all features * fuzzysharp * refactor; 3rd party notice * cutoff=90; no limit; rewrite messages * Include oob migration * format url * resource strings (wip) * regen designer.cs * refactor * strong name sign FuzzySharp.dll * changelog; dict index
1 parent 214c0b9 commit 997b231

File tree

12 files changed

+6981
-37
lines changed

12 files changed

+6981
-37
lines changed

LICENSE.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,5 +301,39 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
301301
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
302302
SOFTWARE.
303303

304+
305+
306+
***************
307+
308+
309+
310+
The software includes the FuzzySharp library. The MIT License set out below is provided for informational purposes only. It is not the license that governs any part of the software.
311+
312+
Provided for Informational Purposes Only
313+
314+
FuzzySharp
315+
316+
MIT License
317+
318+
Copyright (c) 2018
319+
320+
Permission is hereby granted, free of charge, to any person obtaining a copy
321+
of this software and associated documentation files (the "Software"), to deal
322+
in the Software without restriction, including without limitation the rights
323+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
324+
copies of the Software, and to permit persons to whom the Software is
325+
furnished to do so, subject to the following conditions:
326+
327+
The above copyright notice and this permission notice shall be included in all
328+
copies or substantial portions of the Software.
329+
330+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
331+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
332+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
333+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
334+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
335+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
336+
SOFTWARE.
337+
304338
-------------END OF THIRD PARTY NOTICE----------------------------------------
305339

src/Accounts/Accounts/Accounts.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
<ItemGroup>
4343
<EmbeddedResource Include="AzureRmAlias\Mappings.json" />
44+
<EmbeddedResource Include="Utilities\CommandMappings.json" />
4445
</ItemGroup>
4546

4647
<ItemGroup>
@@ -49,6 +50,12 @@
4950
<ProjectReference Include="..\Authenticators\Authenticators.csproj" />
5051
</ItemGroup>
5152

53+
<ItemGroup>
54+
<Reference Include="FuzzySharp">
55+
<HintPath>..\..\lib\FuzzySharp.dll</HintPath>
56+
</Reference>
57+
</ItemGroup>
58+
5259
<ItemGroup>
5360
<Compile Update="Properties\Resources.Designer.cs">
5461
<DesignTime>True</DesignTime>

src/Accounts/Accounts/Az.Accounts.psd1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ RequiredAssemblies = 'Microsoft.Azure.PowerShell.Authentication.Abstractions.dll
7979
'Microsoft.WindowsAzure.Storage.DataMovement.dll',
8080
'Microsoft.Azure.PowerShell.Clients.Aks.dll',
8181
'Microsoft.Azure.PowerShell.Strategies.dll',
82-
'Microsoft.Azure.PowerShell.Common.Share.dll'
82+
'Microsoft.Azure.PowerShell.Common.Share.dll',
83+
'FuzzySharp.dll'
8384

8485
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
8586
# ScriptsToProcess = @()

src/Accounts/Accounts/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
-->
2020

2121
## Upcoming Release
22+
* Supported giving suggestions if an Azure PowerShell command cannot be found, for example when there is a typo in command name.
2223

2324
## Version 2.9.0
2425
* Supported exporting and importing configurations by `Export-AzConfig` and `Import-AzConfig`.

src/Accounts/Accounts/Properties/Resources.Designer.cs

Lines changed: 73 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Accounts/Accounts/Properties/Resources.resx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,4 +540,35 @@
540540
<data name="SubscriptionNotFouldPleaseCheckConfig" xml:space="preserve">
541541
<value>If a subscription is not specified, please check the configs by `Get-AzConfig`.</value>
542542
</data>
543+
<data name="CommandNotFoundAzureRM" xml:space="preserve">
544+
<value>The command {0} is in the AzureRM PowerShell module, which is outdated. See {1} for instructions to migrate to Az.</value>
545+
<comment>0: command name; 1: link to AzureRM migration guide</comment>
546+
</data>
547+
<data name="CommandNotFoundDeprecated" xml:space="preserve">
548+
<value>The command {0} has been deprecated in {1}.</value>
549+
<comment>0: deprecated command name; 1: release name</comment>
550+
</data>
551+
<data name="CommandNotFoundReplaced" xml:space="preserve">
552+
<value>The command {0} has been deprecated and replaced by {1} in {2}.</value>
553+
<comment>0: deprecated command name; 1: command that replaced the deprecated one; 2: release name</comment>
554+
</data>
555+
<data name="SeeMigrationGuide" xml:space="preserve">
556+
<value>Please refer to the migration guide {0}.</value>
557+
<comment>0: link to migration guide</comment>
558+
</data>
559+
<data name="CommandNotFoundFuzzyStringPlural" xml:space="preserve">
560+
<value>{0} is not found. The most similar Azure PowerShell commands are:</value>
561+
<comment>0: command name</comment>
562+
</data>
563+
<data name="CommandNotFoundFuzzyStringSingle" xml:space="preserve">
564+
<value>{0} is not found. The most similar Azure PowerShell command is:</value>
565+
<comment>0: command name</comment>
566+
</data>
567+
<data name="AzureRMToAzMigrationGuideLink" xml:space="preserve">
568+
<value>https://go.microsoft.com/fwlink/?linkid=2202029</value>
569+
</data>
570+
<data name="CommandNotFoundModuleNotInstalled" xml:space="preserve">
571+
<value>The command {0} is part of Azure PowerShell module "{1}" and it is not installed. Run "Install-Module {1}" to install it.</value>
572+
<comment>0: command being not found; 1: its module</comment>
573+
</data>
543574
</root>

0 commit comments

Comments
 (0)