aboutsummaryrefslogtreecommitdiff
path: root/mingling_core/tmpls/comps/pwsh.ps1
diff options
context:
space:
mode:
Diffstat (limited to 'mingling_core/tmpls/comps/pwsh.ps1')
-rw-r--r--mingling_core/tmpls/comps/pwsh.ps138
1 files changed, 22 insertions, 16 deletions
diff --git a/mingling_core/tmpls/comps/pwsh.ps1 b/mingling_core/tmpls/comps/pwsh.ps1
index 8a52a4f..610522b 100644
--- a/mingling_core/tmpls/comps/pwsh.ps1
+++ b/mingling_core/tmpls/comps/pwsh.ps1
@@ -36,35 +36,41 @@ Register-ArgumentCompleter -Native -CommandName '<<<bin_name>>>' -ScriptBlock {
}
$completions | ForEach-Object {
- $path = $_.Replace('^', '-')
+ $path = $_
$isDirectory = $path.EndsWith([System.IO.Path]::DirectorySeparatorChar) -or $path.EndsWith('/')
$completionType = if ($isDirectory) { 'ProviderContainer' } else { 'ProviderItem' }
[System.Management.Automation.CompletionResult]::new($path, $path, $completionType, $path)
}
}
else {
- $parsedCompletions = @()
+ $completionItems = @()
+
foreach ($item in $completions) {
if ($item -match '^([^$]+)\$\((.+)\)$') {
- $parsedCompletions += "$($matches[1]):$($matches[2])"
- }
- else {
- $parsedCompletions += $item
- }
- }
-
- $simpleCompletions = @()
- foreach ($item in $parsedCompletions) {
- if ($item -match '^([^:]+):(.+)$') {
- $simpleCompletions += $matches[1]
+ $text = $matches[1]
+ $description = $matches[2]
+ $completionItems += @{
+ Text = $text
+ Description = $description
+ }
}
else {
- $simpleCompletions += $item
+ $text = $item
+ $completionItems += @{
+ Text = $text
+ Description = $text
+ }
}
}
- return $simpleCompletions | ForEach-Object {
- [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
+ return $completionItems | ForEach-Object {
+ $resultType = if ($_.Text.StartsWith('-')) { 'ParameterName' } else { 'ParameterValue' }
+ [System.Management.Automation.CompletionResult]::new(
+ $_.Text,
+ $_.Text,
+ $resultType,
+ $_.Description
+ )
}
}
}