Skip to content

Commit

Permalink
Update powershell_completions.go
Browse files Browse the repository at this point in the history
Incorporate @bartoncasey insight about typical alias usage in spf13#2049
  • Loading branch information
mavaddat committed Oct 29, 2023
1 parent f43b653 commit caeed9f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions powershell_completions.go
Expand Up @@ -279,12 +279,12 @@ filter __%[1]s_escapeStringWithSpecialChars {
}
}
# Enumerate the cmds for %[1]s (set by System.Environment)
$available%[2]s = Get-Command -Name '%[1]s' -All -ErrorAction SilentlyContinue
$available%[2]s = Get-Command -Name '%[1]s' -All -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Definition -ErrorAction SilentlyContinue
# Enumerate extant aliases for %[1]s (already set by user)
${__%[2]sAliases} = @()
foreach($__%[2]sCmd in $available%[2]s){
$__%[2]sAliases += Get-Alias | Where-Object { $_.Definition -eq ($__%[2]sCmd | Resolve-Path) }
$__%[2]sAliases += Get-Alias | Where-Object { $_ -eq ($__%[2]sCmd | Resolve-Path) -or $_ -eq (Get-Command -Name $_ -ErrorAction SilentlyContinue).Definition}
}
# Register args completer for all cmds and aliases
[string[]]$joint%[2]snames = [array]$available%[2]s.Name + [array]${__%[2]sAliases}.Name + @('%[1]s')
Expand Down

0 comments on commit caeed9f

Please sign in to comment.