mirror of
https://github.com/spf13/cobra
synced 2024-11-04 21:07:19 +00:00
Compare commits
11 commits
66e6e12622
...
8115abd854
Author | SHA1 | Date | |
---|---|---|---|
|
8115abd854 | ||
|
955cac7eb9 | ||
|
94243fef09 | ||
|
8b4835d0a9 | ||
|
c901861b50 | ||
|
caeed9f2a4 | ||
|
f43b653d17 | ||
|
d17f539906 | ||
|
0676e2612e | ||
|
cc6f7e0edd | ||
|
a6a563d656 |
1 changed files with 10 additions and 1 deletions
|
@ -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,
|
`, name, nameForVar, compCmd,
|
||||||
ShellCompDirectiveError, ShellCompDirectiveNoSpace, ShellCompDirectiveNoFileComp,
|
ShellCompDirectiveError, ShellCompDirectiveNoSpace, ShellCompDirectiveNoFileComp,
|
||||||
ShellCompDirectiveFilterFileExt, ShellCompDirectiveFilterDirs, ShellCompDirectiveKeepOrder, activeHelpEnvVar(name)))
|
ShellCompDirectiveFilterFileExt, ShellCompDirectiveFilterDirs, ShellCompDirectiveKeepOrder, activeHelpEnvVar(name)))
|
||||||
|
|
Loading…
Reference in a new issue