Compare commits

...

11 commits

Author SHA1 Message Date
Mavaddat Javid 8115abd854
Merge 955cac7eb9 into bd914e58d6 2024-03-18 12:53:37 +08:00
Mavaddat Javid 955cac7eb9
ignore resolve errors 2023-10-30 11:48:03 -04:00
Mavaddat Javid 94243fef09
need description property 2023-10-30 11:44:11 -04:00
Mavaddat Javid 8b4835d0a9
Merge branch 'spf13:main' into patch-1 2023-10-30 11:03:27 -04:00
Mavaddat Javid c901861b50
Update powershell_completions.go
Typo in previous. Change `$_` PSItem to `$__%[2]sCmd`
2023-10-29 18:47:11 -04:00
Mavaddat Javid caeed9f2a4
Update powershell_completions.go
Incorporate @bartoncasey insight about typical alias usage in https://github.com/spf13/cobra/pull/2049
2023-10-29 17:00:24 -04:00
Mavaddat Javid f43b653d17
Update powershell_completions.go
Preliminary assignment before use
2023-06-19 16:56:55 -04:00
Mavaddat Javid d17f539906
Merge branch 'main' into patch-1 2023-06-19 16:46:04 -04:00
Mavaddat Javid 0676e2612e
Update powershell_completions.go
Implement curly bracket technique like https://github.com/spf13/cobra/pull/1960
2023-06-19 16:44:38 -04:00
Mavaddat Javid cc6f7e0edd
Forgot about the original alias!
In my exuberance to include all the other aliases, I accidentally removed the original alias that was previously the only one being registered for autocompletion. I have restored this `'%[1]s'`.
2023-06-14 11:58:34 -04:00
Mavaddat Javid a6a563d656
completers ∀x∈ {cmds, aliases} in powershell_completions.go
pwsh completers ∀x∈ {cmds, aliases}
2023-06-12 10:46:19 -04:00

View file

@ -278,8 +278,17 @@ 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 | Select-Object -ExpandProperty Definition -ErrorAction SilentlyContinue
Register-ArgumentCompleter -CommandName '%[1]s' -ScriptBlock ${__%[2]sCompleterBlock}
# 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 -ErrorAction SilentlyContinue) -or $_.Definition -eq (Get-Command -Name $__%[2]sCmd -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')
Register-ArgumentCompleter -CommandName $joint%[2]snames -ScriptBlock ${__%[2]sCompleterBlock}
`, name, nameForVar, compCmd,
ShellCompDirectiveError, ShellCompDirectiveNoSpace, ShellCompDirectiveNoFileComp,
ShellCompDirectiveFilterFileExt, ShellCompDirectiveFilterDirs, ShellCompDirectiveKeepOrder, activeHelpEnvVar(name)))