From 5a75afbe22eff8e0cd740d0cd12874ab524d634b Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Sun, 4 Nov 2018 07:40:51 -0800 Subject: [PATCH 1/4] draft of abbreviation expansion tab completion --- ...0000-Abbreviation-Expansion-TabComplete.md | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 1-Draft/RFC0000-Abbreviation-Expansion-TabComplete.md diff --git a/1-Draft/RFC0000-Abbreviation-Expansion-TabComplete.md b/1-Draft/RFC0000-Abbreviation-Expansion-TabComplete.md new file mode 100644 index 00000000..5386c1e7 --- /dev/null +++ b/1-Draft/RFC0000-Abbreviation-Expansion-TabComplete.md @@ -0,0 +1,77 @@ +--- +RFC: RFC0000 +Author: Steve Lee +Status: Draft +SupercededBy: N/A +Version: 1.0 +Area: Engine-CommandCompleter +Comments Due: 12/4/2018 +Plan to implement: Yes +--- + +# Abbreviation expansion based tab completion + +PowerShell rules for cmdlet naming is to be descriptive. +Cloud services cmdlets tend to be granular and vast. + +Azure PowerShell, for example, has a cmdlet called `New-AzSqlServerDisasterRecoveryConfiguration`. +If you start with `New-Az` and hit tab, you'll get 334 matches. +Then you continue typing `New-AzSql` and hit tab, you still get 19 matches. + +These cmdlets typically do not have aliases since the aliases would be very long. + +## Motivation + + As a PowerShell user, + I can tab complete long cmdlet names easily and predictably, + so that I can be more efficient using PowerShell interactively. + +## Specification + +Since PowerShell rule for cmdlet naming relies on Pascal Casing, +you can consistently predict a long cmdlet name used often by simply specifying +the uppercase letters: + +```none +PS /Users/steve> n-assdrc + +becomes + +PS /Users/steve> New-AzSqlServerDisasterRecoveryConfiguration +``` + +The dash is still required to avoid short abbreviations from conflicting with aliases. +The abbreviation is not an alias as it does not work if specified on the command +line or script: + +```none +PS /Users/steve> n-assdrc +n-assdrc : The term 'n-assdrc' is not recognized as the name of a cmdlet, function, script file, or operable program. +Check the spelling of the name, or if a path was included, verify that the path is correct and try again. +At line:1 char:1 ++ n-assdrc ++ ~~~~~~~~ ++ CategoryInfo : ObjectNotFound: (n-assdrc:String) [], CommandNotFoundException ++ FullyQualifiedErrorId : CommandNotFoundException +``` + +This feature is intended only to be used interactively with tab completion. + +Even shorter commands can benefit: + +```none +PS /Users/steve> ct-j + +becomes + +PS /Users/steve> ConvertTo-Json +``` + +## Alternate Proposals and Considerations + +PowerShell convention is for 2 letter abbreviations to entirely be in uppercase. +So you have cmdlets like `Set-AzVM`. +The abbreviated form is `s-avm`, not `s-av` which might be expected. + +This feature is not dynamic aliases as readability of scripts would be significantly +impacted if `n-assdrc` was allowed in scripts. From 4a6f57b62361769d316bf50b5870a055ea087029 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Thu, 24 Jan 2019 11:05:36 -0800 Subject: [PATCH 2/4] add comments as additional considerations --- 1-Draft/RFC0000-Abbreviation-Expansion-TabComplete.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/1-Draft/RFC0000-Abbreviation-Expansion-TabComplete.md b/1-Draft/RFC0000-Abbreviation-Expansion-TabComplete.md index 5386c1e7..bf3f02b5 100644 --- a/1-Draft/RFC0000-Abbreviation-Expansion-TabComplete.md +++ b/1-Draft/RFC0000-Abbreviation-Expansion-TabComplete.md @@ -75,3 +75,13 @@ The abbreviated form is `s-avm`, not `s-av` which might be expected. This feature is not dynamic aliases as readability of scripts would be significantly impacted if `n-assdrc` was allowed in scripts. + +Partial support where just verb or noun is abbreviated is not supported. +This could be added in the future based on customer feedback. + +Fuzzy matching is not in scope of this RFC. +Fuzzy matching for [suggestions on CommandNotFoundException](https://github.com/PowerShell/PowerShell/pull/8458) +was implemented and could be used as a base for supporting tab completion. + +If more variants/algorithms are supported, we may need a way to allow the user +to pick which ones they want to use. From bffab299cc6e4cafba506d11a1e31723520a9366 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Mon, 28 Jan 2019 12:42:45 -0800 Subject: [PATCH 3/4] Update RFC0000-Abbreviation-Expansion-TabComplete.md --- ...0000-Abbreviation-Expansion-TabComplete.md | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/1-Draft/RFC0000-Abbreviation-Expansion-TabComplete.md b/1-Draft/RFC0000-Abbreviation-Expansion-TabComplete.md index bf3f02b5..b29d4742 100644 --- a/1-Draft/RFC0000-Abbreviation-Expansion-TabComplete.md +++ b/1-Draft/RFC0000-Abbreviation-Expansion-TabComplete.md @@ -1,7 +1,7 @@ --- -RFC: RFC0000 +RFC: RFC0030 Author: Steve Lee -Status: Draft +Status: Experimental-Accepted SupercededBy: N/A Version: 1.0 Area: Engine-CommandCompleter @@ -85,3 +85,26 @@ was implemented and could be used as a base for supporting tab completion. If more variants/algorithms are supported, we may need a way to allow the user to pick which ones they want to use. + +--------------- +## PowerShell Committee Decision + +### Voting Results + +Joey Aiello: Accept + +Bruce Payette: Accept + +Steve Lee: Accept + +Hemant Mahawar: Accept + +Jim Truher: Accept + +### Majority Decision + +Committee agrees that the RFC is complete for the targeted scenario and additional enhancement requires are out of scope and should be separate RFCs. + +### Minority Decision + +N/A From e46f37bc4c1de574ea6f72911f57ac328a5d0c3a Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Mon, 28 Jan 2019 13:00:42 -0800 Subject: [PATCH 4/4] Rename RFC0000-Abbreviation-Expansion-TabComplete.md to RFC0030-Abbreviation-Expansion-TabComplete.md --- ...bComplete.md => RFC0030-Abbreviation-Expansion-TabComplete.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename 1-Draft/{RFC0000-Abbreviation-Expansion-TabComplete.md => RFC0030-Abbreviation-Expansion-TabComplete.md} (100%) diff --git a/1-Draft/RFC0000-Abbreviation-Expansion-TabComplete.md b/1-Draft/RFC0030-Abbreviation-Expansion-TabComplete.md similarity index 100% rename from 1-Draft/RFC0000-Abbreviation-Expansion-TabComplete.md rename to 1-Draft/RFC0030-Abbreviation-Expansion-TabComplete.md