|
| 1 | +--- |
| 2 | +RFC: RFC0030 |
| 3 | +Author: Steve Lee |
| 4 | +Status: Experimental-Accepted |
| 5 | +SupercededBy: N/A |
| 6 | +Version: 1.0 |
| 7 | +Area: Engine-CommandCompleter |
| 8 | +Comments Due: 12/4/2018 |
| 9 | +Plan to implement: Yes |
| 10 | +--- |
| 11 | + |
| 12 | +# Abbreviation expansion based tab completion |
| 13 | + |
| 14 | +PowerShell rules for cmdlet naming is to be descriptive. |
| 15 | +Cloud services cmdlets tend to be granular and vast. |
| 16 | + |
| 17 | +Azure PowerShell, for example, has a cmdlet called `New-AzSqlServerDisasterRecoveryConfiguration`. |
| 18 | +If you start with `New-Az` and hit tab, you'll get 334 matches. |
| 19 | +Then you continue typing `New-AzSql` and hit tab, you still get 19 matches. |
| 20 | + |
| 21 | +These cmdlets typically do not have aliases since the aliases would be very long. |
| 22 | + |
| 23 | +## Motivation |
| 24 | + |
| 25 | + As a PowerShell user, |
| 26 | + I can tab complete long cmdlet names easily and predictably, |
| 27 | + so that I can be more efficient using PowerShell interactively. |
| 28 | + |
| 29 | +## Specification |
| 30 | + |
| 31 | +Since PowerShell rule for cmdlet naming relies on Pascal Casing, |
| 32 | +you can consistently predict a long cmdlet name used often by simply specifying |
| 33 | +the uppercase letters: |
| 34 | + |
| 35 | +```none |
| 36 | +PS /Users/steve> n-assdrc<tab> |
| 37 | +
|
| 38 | +becomes |
| 39 | +
|
| 40 | +PS /Users/steve> New-AzSqlServerDisasterRecoveryConfiguration |
| 41 | +``` |
| 42 | + |
| 43 | +The dash is still required to avoid short abbreviations from conflicting with aliases. |
| 44 | +The abbreviation is not an alias as it does not work if specified on the command |
| 45 | +line or script: |
| 46 | + |
| 47 | +```none |
| 48 | +PS /Users/steve> n-assdrc |
| 49 | +n-assdrc : The term 'n-assdrc' is not recognized as the name of a cmdlet, function, script file, or operable program. |
| 50 | +Check the spelling of the name, or if a path was included, verify that the path is correct and try again. |
| 51 | +At line:1 char:1 |
| 52 | ++ n-assdrc |
| 53 | ++ ~~~~~~~~ |
| 54 | ++ CategoryInfo : ObjectNotFound: (n-assdrc:String) [], CommandNotFoundException |
| 55 | ++ FullyQualifiedErrorId : CommandNotFoundException |
| 56 | +``` |
| 57 | + |
| 58 | +This feature is intended only to be used interactively with tab completion. |
| 59 | + |
| 60 | +Even shorter commands can benefit: |
| 61 | + |
| 62 | +```none |
| 63 | +PS /Users/steve> ct-j<tab> |
| 64 | +
|
| 65 | +becomes |
| 66 | +
|
| 67 | +PS /Users/steve> ConvertTo-Json |
| 68 | +``` |
| 69 | + |
| 70 | +## Alternate Proposals and Considerations |
| 71 | + |
| 72 | +PowerShell convention is for 2 letter abbreviations to entirely be in uppercase. |
| 73 | +So you have cmdlets like `Set-AzVM`. |
| 74 | +The abbreviated form is `s-avm`, not `s-av` which might be expected. |
| 75 | + |
| 76 | +This feature is not dynamic aliases as readability of scripts would be significantly |
| 77 | +impacted if `n-assdrc` was allowed in scripts. |
| 78 | + |
| 79 | +Partial support where just verb or noun is abbreviated is not supported. |
| 80 | +This could be added in the future based on customer feedback. |
| 81 | + |
| 82 | +Fuzzy matching is not in scope of this RFC. |
| 83 | +Fuzzy matching for [suggestions on CommandNotFoundException](https://github.com/PowerShell/PowerShell/pull/8458) |
| 84 | +was implemented and could be used as a base for supporting tab completion. |
| 85 | + |
| 86 | +If more variants/algorithms are supported, we may need a way to allow the user |
| 87 | +to pick which ones they want to use. |
| 88 | + |
| 89 | +--------------- |
| 90 | +## PowerShell Committee Decision |
| 91 | + |
| 92 | +### Voting Results |
| 93 | + |
| 94 | +Joey Aiello: Accept |
| 95 | + |
| 96 | +Bruce Payette: Accept |
| 97 | + |
| 98 | +Steve Lee: Accept |
| 99 | + |
| 100 | +Hemant Mahawar: Accept |
| 101 | + |
| 102 | +Jim Truher: Accept |
| 103 | + |
| 104 | +### Majority Decision |
| 105 | + |
| 106 | +Committee agrees that the RFC is complete for the targeted scenario and additional enhancement requires are out of scope and should be separate RFCs. |
| 107 | + |
| 108 | +### Minority Decision |
| 109 | + |
| 110 | +N/A |
0 commit comments