From 38e2e5dd964e5b1d465524d8449c90c79fb32c68 Mon Sep 17 00:00:00 2001 From: abgox Date: Thu, 15 Aug 2024 07:53:42 +0800 Subject: [PATCH] feat(completions): update --- completions/git/guid.txt | 2 +- completions/git/hooks.ps1 | 102 ++++++++++++++++++------------------ completions/npm/guid.txt | 2 +- completions/npm/hooks.ps1 | 31 +++++------ completions/pnpm/guid.txt | 2 +- completions/pnpm/hooks.ps1 | 42 +++++++-------- completions/psc/guid.txt | 2 +- completions/psc/hooks.ps1 | 56 ++++++++++---------- completions/scoop/guid.txt | 2 +- completions/scoop/hooks.ps1 | 34 ++++++------ completions/volta/guid.txt | 2 +- completions/volta/hooks.ps1 | 18 +++---- completions/wsl/guid.txt | 2 +- completions/wsl/hooks.ps1 | 47 +++++++++-------- completions/yarn/guid.txt | 2 +- completions/yarn/hooks.ps1 | 29 +++++----- 16 files changed, 186 insertions(+), 189 deletions(-) diff --git a/completions/git/guid.txt b/completions/git/guid.txt index 8471951c..862a07dd 100644 --- a/completions/git/guid.txt +++ b/completions/git/guid.txt @@ -1 +1 @@ -bed7a5be-afde-4726-adb4-4542ebaa9a95 +a7339dd8-1703-493b-afba-3cd3c17b6e03 diff --git a/completions/git/hooks.ps1 b/completions/git/hooks.ps1 index 2c18f90e..91bd46cc 100644 --- a/completions/git/hooks.ps1 +++ b/completions/git/hooks.ps1 @@ -1,17 +1,17 @@ -function handleCompletions([System.Collections.Generic.List[System.Object]]$completions) { - $tempList = [System.Collections.Generic.List[System.Object]]@() - function addCompletion($name, $tip = ' ', $symbol = '') { +function handleCompletions($completions) { + $tempList = @() + function returnCompletion($name, $tip = ' ', $symbol = '') { $symbols = foreach ($c in ($symbol -split ' ')) { $PSCompletions.config."symbol_$($c)" } $symbols = $symbols -join '' $padSymbols = if ($symbols) { "$($PSCompletions.config.menu_between_item_and_symbol)$($symbols)" }else { '' } $cmd_arr = $name -split ' ' - $tempList.Add(@{ - name = $name - ListItemText = "$($cmd_arr[-1])$($padSymbols)" - CompletionText = $cmd_arr[-1] - ToolTip = $tip - }) + @{ + name = $name + ListItemText = "$($cmd_arr[-1])$($padSymbols)" + CompletionText = $cmd_arr[-1] + ToolTip = $tip + } } $branch_list = git branch --format='%(refname:lstrip=2)' 2>$null $head_list = @{ @@ -28,18 +28,19 @@ function handleCompletions([System.Collections.Generic.List[System.Object]]$comp $branch_head_list = $branch_list + $head_list.Keys $remote_list = git remote 2>$null $commit_info = [System.Collections.Generic.List[array]]::new() - $current_commit = [System.Collections.Generic.List[string]]::new() if ($PSCompletions.config.comp_config.git.max_commit -in @('', $null)) { $PSCompletions.config.comp_config.git.max_commit = 20 } - $git_info = git log --pretty='format:%h%nDate: %cr%nAuthor: %an <%ae>%n%B%n@@@--------------------@@@' -n $PSCompletions.config.comp_config.git.max_commit --encoding=gbk 2>$null + $guid = [guid]::NewGuid().Guid + $git_info = git log --pretty="format:%h%nDate: %cr%nAuthor: %an <%ae>%n%B%n$($guid)" -n $PSCompletions.config.comp_config.git.max_commit --encoding=gbk 2>$null + $current_commit = @() foreach ($_ in $git_info) { - if ($_ -ne '@@@--------------------@@@') { - $current_commit.Add($_) + if ($_ -ne $guid) { + $current_commit += $_ } else { $commit_info.add($current_commit) - $current_commit = [System.Collections.Generic.List[string]]::new() + $current_commit = @() } } $current_commit = $null @@ -47,34 +48,33 @@ function handleCompletions([System.Collections.Generic.List[System.Object]]$comp foreach ($_ in $branch_list) { $info = 'branch --- ' + $_ - - addCompletion "switch $($_)" $info - addCompletion "merge $($_)" $info - addCompletion "diff $($_)" $info + $tempList += returnCompletion "switch $($_)" $info + $tempList += returnCompletion "branch $($_)" $info + $tempList += returnCompletion "merge $($_)" $info + $tempList += returnCompletion "diff $($_)" $info } foreach ($_ in $head_list.Keys) { $info = $head_list.$_ - addCompletion "rebase -i $($_)" $info - addCompletion "rebase --interactive $($_)" $info - addCompletion "diff $($_)" $info - addCompletion "reset $($_)" $info - addCompletion "reset --soft $($_)" $info - addCompletion "reset --hard $($_)" $info - addCompletion "reset --mixed $($_)" $info - addCompletion "show $($_)" $info + $tempList += returnCompletion "rebase -i $($_)" $info + $tempList += returnCompletion "rebase --interactive $($_)" $info + $tempList += returnCompletion "diff $($_)" $info + $tempList += returnCompletion "reset $($_)" $info + $tempList += returnCompletion "reset --soft $($_)" $info + $tempList += returnCompletion "reset --hard $($_)" $info + $tempList += returnCompletion "reset --mixed $($_)" $info + $tempList += returnCompletion "show $($_)" $info } foreach ($_ in $branch_head_list) { $info = if ($head_list.$_) { $head_list.$_ }else { 'branch --- ' + $_ } - addCompletion "checkout $($_)" $info + $tempList += returnCompletion "checkout $($_)" $info } foreach ($_ in $remote_list) { $info = 'remote --- ' + $_ - addCompletion "push $($_)" $info - - addCompletion "pull $($_)" $info - addCompletion "fetch $($_)" $info - addCompletion "remote rename $($_)" $info - addCompletion "remote rm $($_)" $info + $tempList += returnCompletion "push $($_)" $info + $tempList += returnCompletion "pull $($_)" $info + $tempList += returnCompletion "fetch $($_)" $info + $tempList += returnCompletion "remote rename $($_)" $info + $tempList += returnCompletion "remote rm $($_)" $info } foreach ($_ in $commit_info) { $hash = $_[0] @@ -83,30 +83,30 @@ function handleCompletions([System.Collections.Generic.List[System.Object]]$comp $commit = $_[3..($_.Length - 1)] $content = $date + "`n" + $author + "`n" + ($commit -join "`n") - addCompletion "commit -C $($hash)" $content - addCompletion "rebase -i $($hash)" $content - addCompletion "rebase --interactive $($hash)" $content - addCompletion "checkout $($hash)" $content - addCompletion "diff $($hash)" $content - addCompletion "reset $($hash)" $content - addCompletion "reset --soft $($hash)" $content - addCompletion "reset --hard $($hash)" $content - addCompletion "reset --mixed $($hash)" $content - addCompletion "show $($hash)" $content - addCompletion "revert $($hash)" $content - addCompletion "commit $($hash)" $content + $tempList += returnCompletion "commit -C $($hash)" $content + $tempList += returnCompletion "rebase -i $($hash)" $content + $tempList += returnCompletion "rebase --interactive $($hash)" $content + $tempList += returnCompletion "checkout $($hash)" $content + $tempList += returnCompletion "diff $($hash)" $content + $tempList += returnCompletion "reset $($hash)" $content + $tempList += returnCompletion "reset --soft $($hash)" $content + $tempList += returnCompletion "reset --hard $($hash)" $content + $tempList += returnCompletion "reset --mixed $($hash)" $content + $tempList += returnCompletion "show $($hash)" $content + $tempList += returnCompletion "revert $($hash)" $content + $tempList += returnCompletion "commit $($hash)" $content } foreach ($_ in $tag_list) { - addCompletion "tag -d $($_)" "tag --- $($_)" - addCompletion "tag -v $($_)" "tag --- $($_)" + $tempList += returnCompletion "tag -d $($_)" "tag --- $($_)" + $tempList += returnCompletion "tag -v $($_)" "tag --- $($_)" } foreach ($_ in git stash list --encoding=gbk 2>$null) { if ($_ -match 'stash@\{(\d+)\}') { $stashId = $matches[1] - addCompletion "stash show $stashId" $_ - addCompletion "stash pop $stashId" $_ - addCompletion "stash apply $stashId" $_ - addCompletion "stash drop $stashId" $_ + $tempList += returnCompletion "stash show $stashId" $_ + $tempList += returnCompletion "stash pop $stashId" $_ + $tempList += returnCompletion "stash apply $stashId" $_ + $tempList += returnCompletion "stash drop $stashId" $_ } } return $tempList + $completions diff --git a/completions/npm/guid.txt b/completions/npm/guid.txt index 9bcc25a1..0d3c85a1 100644 --- a/completions/npm/guid.txt +++ b/completions/npm/guid.txt @@ -1 +1 @@ -3423b6ac-24b2-4e8f-9fbb-964ea7ade1f8 +277f9e8e-4ec9-42f5-bb65-611340c68837 diff --git a/completions/npm/hooks.ps1 b/completions/npm/hooks.ps1 index e0b40ab2..1316703e 100644 --- a/completions/npm/hooks.ps1 +++ b/completions/npm/hooks.ps1 @@ -1,19 +1,18 @@ -function handleCompletions([System.Collections.Generic.List[System.Object]]$completions) { +function handleCompletions($completions) { if (!(Test-Path "package.json")) { return $completions } - - $tempList = [System.Collections.Generic.List[System.Object]]@() - function addCompletion($name, $tip = ' ', $symbol = '') { + $tempList = @() + function returnCompletion($name, $tip = ' ', $symbol = '') { $symbols = foreach ($c in ($symbol -split ' ')) { $PSCompletions.config."symbol_$($c)" } $symbols = $symbols -join '' $padSymbols = if ($symbols) { "$($PSCompletions.config.menu_between_item_and_symbol)$($symbols)" }else { '' } $cmd_arr = $name -split ' ' - $tempList.Add(@{ - name = $name - ListItemText = "$($cmd_arr[-1])$($padSymbols)" - CompletionText = $cmd_arr[-1] - ToolTip = $tip - }) + @{ + name = $name + ListItemText = "$($cmd_arr[-1])$($padSymbols)" + CompletionText = $cmd_arr[-1] + ToolTip = $tip + } } $packageJson = $PSCompletions.ConvertFrom_JsonToHashtable((Get-Content "package.json" -Raw)) @@ -22,21 +21,19 @@ function handleCompletions([System.Collections.Generic.List[System.Object]]$comp $devDependencies = $packageJson.devDependencies if ($scripts) { foreach ($script in $scripts.Keys) { - addCompletion "run $script" "package.json scripts:`n$($scripts.$script)" + $tempList += returnCompletion "run $script" "package.json scripts:`n$($scripts.$script)" } } if ($dependencies) { foreach ($dependency in $dependencies.Keys) { - addCompletion "uninstall $dependency" "Uninstall dependency: $($dependency) ($($dependencies.$dependency))" - - addCompletion "update $dependency" "Current Version: $($dependencies.$dependency)" + $tempList += returnCompletion "uninstall $dependency" "Uninstall dependency: $($dependency) ($($dependencies.$dependency))" + $tempList += returnCompletion "update $dependency" "Current Version: $($dependencies.$dependency)" } } if ($devDependencies) { foreach ($devDependency in $devDependencies.Keys) { - addCompletion "uninstall $devDependency" "Uninstall devDependency: $($devDependency) ($($devDependencies.$devDependency))" - - addCompletion "update $devDependency" "Current Version: $($devDependencies.$devDependency)" + $tempList += returnCompletion "uninstall $devDependency" "Uninstall devDependency: $($devDependency) ($($devDependencies.$devDependency))" + $tempList += returnCompletion "update $devDependency" "Current Version: $($devDependencies.$devDependency)" } } return $tempList + $completions diff --git a/completions/pnpm/guid.txt b/completions/pnpm/guid.txt index c44c7aaf..ced18af6 100644 --- a/completions/pnpm/guid.txt +++ b/completions/pnpm/guid.txt @@ -1 +1 @@ -cc5dbb96-873d-4a3e-807f-d1e988754ebe +152b6ccf-ea80-4bc0-8b1f-2f0529b3a2dd diff --git a/completions/pnpm/hooks.ps1 b/completions/pnpm/hooks.ps1 index 7c65fcdd..49e5b1f8 100644 --- a/completions/pnpm/hooks.ps1 +++ b/completions/pnpm/hooks.ps1 @@ -1,18 +1,18 @@ -function handleCompletions([System.Collections.Generic.List[System.Object]]$completions) { +function handleCompletions($completions) { if (!(Test-Path "package.json")) { return $completions } - - function addCompletion($name, $tip = ' ', $symbol = '') { + $tempList = @() + function returnCompletion($name, $tip = ' ', $symbol = '') { $symbols = foreach ($c in ($symbol -split ' ')) { $PSCompletions.config."symbol_$($c)" } $symbols = $symbols -join '' $padSymbols = if ($symbols) { "$($PSCompletions.config.menu_between_item_and_symbol)$($symbols)" }else { '' } $cmd_arr = $name -split ' ' - $completions.Add(@{ - name = $name - ListItemText = "$($cmd_arr[-1])$($padSymbols)" - CompletionText = $cmd_arr[-1] - ToolTip = $tip - }) + @{ + name = $name + ListItemText = "$($cmd_arr[-1])$($padSymbols)" + CompletionText = $cmd_arr[-1] + ToolTip = $tip + } } $packageJson = $PSCompletions.ConvertFrom_JsonToHashtable((Get-Content "package.json" -Raw)) @@ -21,28 +21,28 @@ function handleCompletions([System.Collections.Generic.List[System.Object]]$comp $devDependencies = $packageJson.devDependencies if ($scripts) { foreach ($script in $scripts.Keys) { - addCompletion "run $script" "package.json scripts:`n$($scripts.$script)" + $tempList += returnCompletion "run $script" "package.json scripts:`n$($scripts.$script)" } } if ($dependencies) { foreach ($dependency in $dependencies.Keys) { - addCompletion "rm $dependency" "Remove dependency: $($dependency) ($($dependencies.$dependency))" - addCompletion "remove $dependency" "Remove dependency: $($dependency) ($($dependencies.$dependency))" + $tempList += returnCompletion "rm $dependency" "Remove dependency: $($dependency) ($($dependencies.$dependency))" + $tempList += returnCompletion "remove $dependency" "Remove dependency: $($dependency) ($($dependencies.$dependency))" - addCompletion "update $dependency" "Current Version: $($dependencies.$dependency)" - addCompletion "up $dependency" "Current Version: $($dependencies.$dependency)" - addCompletion "upgrade $dependency" "Current Version: $($dependencies.$dependency)" + $tempList += returnCompletion "update $dependency" "Current Version: $($dependencies.$dependency)" + $tempList += returnCompletion "up $dependency" "Current Version: $($dependencies.$dependency)" + $tempList += returnCompletion "upgrade $dependency" "Current Version: $($dependencies.$dependency)" } } if ($devDependencies) { foreach ($devDependency in $devDependencies.Keys) { - addCompletion "rm $devDependency" "Remove devDependency: $($devDependency) ($($devDependencies.$devDependency))" - addCompletion "remove $devDependency" "Remove devDependency: $($devDependency) ($($devDependencies.$devDependency))" + $tempList += returnCompletion "rm $devDependency" "Remove devDependency: $($devDependency) ($($devDependencies.$devDependency))" + $tempList += returnCompletion "remove $devDependency" "Remove devDependency: $($devDependency) ($($devDependencies.$devDependency))" - addCompletion "update $devDependency" "Current Version: $($devDependencies.$devDependency)" - addCompletion "up $devDependency" "Current Version: $($devDependencies.$devDependency)" - addCompletion "upgrade $devDependency" "Current Version: $($devDependencies.$devDependency)" + $tempList += returnCompletion "update $devDependency" "Current Version: $($devDependencies.$devDependency)" + $tempList += returnCompletion "up $devDependency" "Current Version: $($devDependencies.$devDependency)" + $tempList += returnCompletion "upgrade $devDependency" "Current Version: $($devDependencies.$devDependency)" } } - return $completions + return $tempList + $completions } diff --git a/completions/psc/guid.txt b/completions/psc/guid.txt index ae1929ea..9de92f33 100644 --- a/completions/psc/guid.txt +++ b/completions/psc/guid.txt @@ -1 +1 @@ -00c11c0d-1904-4603-9e57-38717e60e21d +e3fc0933-4ae6-4d9c-8c04-4480dd8d5929 diff --git a/completions/psc/hooks.ps1 b/completions/psc/hooks.ps1 index 4a351646..c420e088 100644 --- a/completions/psc/hooks.ps1 +++ b/completions/psc/hooks.ps1 @@ -1,81 +1,81 @@ -function handleCompletions([System.Collections.Generic.List[System.Object]]$completions) { - function addCompletion($name, $tip = ' ', $symbol = '') { +function handleCompletions($completions) { + function returnCompletion($name, $tip = ' ', $symbol = '') { $symbols = foreach ($c in ($symbol -split ' ')) { $PSCompletions.config."symbol_$($c)" } $symbols = $symbols -join '' $padSymbols = if ($symbols) { "$($PSCompletions.config.menu_between_item_and_symbol)$($symbols)" }else { '' } $cmd_arr = $name -split ' ' - $completions.Add(@{ - name = $name - ListItemText = "$($cmd_arr[-1])$($padSymbols)" - CompletionText = $cmd_arr[-1] - ToolTip = $tip - }) + @{ + name = $name + ListItemText = "$($cmd_arr[-1])$($padSymbols)" + CompletionText = $cmd_arr[-1] + ToolTip = $tip + } } foreach ($completion in $PSCompletions.cmd.Keys) { - addCompletion "rm $($completion)" $PSCompletions.replace_content($PSCompletions.info.rm.tip) + $completions += returnCompletion "rm $($completion)" $PSCompletions.replace_content($PSCompletions.info.rm.tip) - addCompletion "which $($completion)" $PSCompletions.replace_content($PSCompletions.info.which.tip) + $completions += returnCompletion "which $($completion)" $PSCompletions.replace_content($PSCompletions.info.which.tip) - addCompletion "alias add $($completion)" $PSCompletions.replace_content($PSCompletions.info.alias.add.tip) + $completions += returnCompletion "alias add $($completion)" $PSCompletions.replace_content($PSCompletions.info.alias.add.tip) - addCompletion "alias rm $($completion)" $PSCompletions.replace_content($PSCompletions.info.alias.rm.tip) 'SpaceTab' + $completions += returnCompletion "alias rm $($completion)" $PSCompletions.replace_content($PSCompletions.info.alias.rm.tip) 'SpaceTab' foreach ($alias in $PSCompletions.cmd.$completion) { - addCompletion "alias rm $($completion) $($alias)" $PSCompletions.replace_content($PSCompletions.info.alias.rm.tip_v) + $completions += returnCompletion "alias rm $($completion) $($alias)" $PSCompletions.replace_content($PSCompletions.info.alias.rm.tip_v) } - addCompletion "completion $($completion)" $PSCompletions.replace_content($PSCompletions.info.completion.tip) 'SpaceTab' - addCompletion "completion $($completion) language" $PSCompletions.replace_content($PSCompletions.info.completion.language.tip) 'SpaceTab' - addCompletion "completion $($completion) menu_show_tip" $PSCompletions.replace_content($PSCompletions.info.completion.menu_show_tip.tip) 'SpaceTab' + $completions += returnCompletion "completion $($completion)" $PSCompletions.replace_content($PSCompletions.info.completion.tip) 'SpaceTab' + $completions += returnCompletion "completion $($completion) language" $PSCompletions.replace_content($PSCompletions.info.completion.language.tip) 'SpaceTab' + $completions += returnCompletion "completion $($completion) menu_show_tip" $PSCompletions.replace_content($PSCompletions.info.completion.menu_show_tip.tip) 'SpaceTab' - addCompletion "completion $($completion) menu_show_tip 1" $PSCompletions.replace_content($PSCompletions.info.completion.menu_show_tip.tip_v1) - addCompletion "completion $($completion) menu_show_tip 0" $PSCompletions.replace_content($PSCompletions.info.completion.menu_show_tip.tip_v0) + $completions += returnCompletion "completion $($completion) menu_show_tip 1" $PSCompletions.replace_content($PSCompletions.info.completion.menu_show_tip.tip_v1) + $completions += returnCompletion "completion $($completion) menu_show_tip 0" $PSCompletions.replace_content($PSCompletions.info.completion.menu_show_tip.tip_v0) $language = $PSCompletions.get_language($completion) $config = $PSCompletions.get_raw_content("$($PSCompletions.path.completions)/$($completion)/config.json") | ConvertFrom-Json $json = $PSCompletions.get_raw_content("$($PSCompletions.path.completions)/$($completion)/language/$($language).json") | ConvertFrom-Json foreach ($language in $config.language) { - addCompletion "completion $($completion) language $($language)" $PSCompletions.replace_content($PSCompletions.info.completion.language.tip_v) + $completions += returnCompletion "completion $($completion) language $($language)" $PSCompletions.replace_content($PSCompletions.info.completion.language.tip_v) } foreach ($c in $json.config) { $tip = $PSCompletions.replace_content($c.tip) -replace '<\@\w+>', '' if ($c.values) { - addCompletion "completion $($completion) $($c.name)" $tip 'SpaceTab' + $completions += returnCompletion "completion $($completion) $($c.name)" $tip 'SpaceTab' foreach ($value in $c.values) { - addCompletion "completion $($completion) $($c.name) $($value)" $PSCompletions.replace_content($PSCompletions.info.completion.tip_v) + $completions += returnCompletion "completion $($completion) $($c.name) $($value)" $PSCompletions.replace_content($PSCompletions.info.completion.tip_v) } } else { - addCompletion "completion $($completion) $($c.name)" $tip + $completions += returnCompletion "completion $($completion) $($c.name)" $tip } $config_item = $c.name - addCompletion "reset completion $($completion) $($config_item)" $PSCompletions.replace_content($PSCompletions.info.reset.completion.tip_v) + $completions += returnCompletion "reset completion $($completion) $($config_item)" $PSCompletions.replace_content($PSCompletions.info.reset.completion.tip_v) } - addCompletion "reset alias $($completion)" $PSCompletions.replace_content($PSCompletions.info.reset.alias.tip) + $completions += returnCompletion "reset alias $($completion)" $PSCompletions.replace_content($PSCompletions.info.reset.alias.tip) $symbol = if ($json.config) { 'SpaceTab' }else { '' } - addCompletion "reset completion $($completion)" $PSCompletions.replace_content($PSCompletions.info.reset.completion.tip) $symbol + $completions += returnCompletion "reset completion $($completion)" $PSCompletions.replace_content($PSCompletions.info.reset.completion.tip) $symbol } foreach ($completion in $PSCompletions.list) { if ($completion -notin $PSCompletions.cmd.Keys) { - addCompletion "add $($completion)" $PSCompletions.replace_content($PSCompletions.info.add.tip) + $completions += returnCompletion "add $($completion)" $PSCompletions.replace_content($PSCompletions.info.add.tip) } } foreach ($completion in $PSCompletions.update) { - addCompletion "update $($completion)" $PSCompletions.replace_content($PSCompletions.info.update.tip) + $completions += returnCompletion "update $($completion)" $PSCompletions.replace_content($PSCompletions.info.update.tip) } foreach ($item in $PSCompletions.menu.const.color_item) { foreach ($color in $PSCompletions.menu.const.color_value) { - addCompletion "menu custom color $($item) $($color)" $PSCompletions.replace_content($PSCompletions.info.menu.custom.color.tip) + $completions += returnCompletion "menu custom color $($item) $($color)" $PSCompletions.replace_content($PSCompletions.info.menu.custom.color.tip) } } return $completions diff --git a/completions/scoop/guid.txt b/completions/scoop/guid.txt index 155fca5c..aaa1fb9b 100644 --- a/completions/scoop/guid.txt +++ b/completions/scoop/guid.txt @@ -1 +1 @@ -5782d8a2-0236-474e-87cb-554d63b6608a +cac15449-69cc-4d48-918a-6572b7353cbc diff --git a/completions/scoop/hooks.ps1 b/completions/scoop/hooks.ps1 index 3d57c1bb..bcf3c4e6 100644 --- a/completions/scoop/hooks.ps1 +++ b/completions/scoop/hooks.ps1 @@ -1,16 +1,16 @@ -function handleCompletions([System.Collections.Generic.List[System.Object]]$completions) { - function addCompletion($name, $tip = ' ', $symbol = '') { +function handleCompletions($completions) { + function returnCompletion($name, $tip = ' ', $symbol = '') { $symbols = foreach ($c in ($symbol -split ' ')) { $PSCompletions.config."symbol_$($c)" } $symbols = $symbols -join '' $padSymbols = if ($symbols) { "$($PSCompletions.config.menu_between_item_and_symbol)$($symbols)" }else { '' } $cmd_arr = $name -split ' ' - $completions.Add(@{ - name = $name - ListItemText = "$($cmd_arr[-1])$($padSymbols)" - CompletionText = $cmd_arr[-1] - ToolTip = $tip - }) + @{ + name = $name + ListItemText = "$($cmd_arr[-1])$($padSymbols)" + CompletionText = $cmd_arr[-1] + ToolTip = $tip + } } if ($PSVersionTable.Platform -ne 'Unix') { @@ -35,22 +35,22 @@ function handleCompletions([System.Collections.Generic.List[System.Object]]$comp } foreach ($_ in scoop bucket known) { $bucket = $_ - addCompletion "bucket add $($bucket)" $PSCompletions.replace_content($PSCompletions.data.scoop.info.tip.bucket.add) + $completions += returnCompletion "bucket add $($bucket)" $PSCompletions.replace_content($PSCompletions.data.scoop.info.tip.bucket.add) } foreach ($_ in Get-ChildItem "$scoop_path\buckets" 2>$null) { $bucket = $_.Name - addCompletion "bucket rm $($bucket)" $PSCompletions.replace_content($PSCompletions.data.scoop.info.tip.bucket.rm) + $completions += returnCompletion "bucket rm $($bucket)" $PSCompletions.replace_content($PSCompletions.data.scoop.info.tip.bucket.rm) } foreach ($_ in @("$scoop_path\apps", "$scoop_global_path\apps")) { foreach ($item in (Get-ChildItem $_ 2>$null)) { $app = $item.Name $path = $item.FullName - addCompletion "uninstall $($app)" $PSCompletions.replace_content($PSCompletions.data.scoop.info.tip.uninstall) - addCompletion "update $($app)" $PSCompletions.replace_content($PSCompletions.data.scoop.info.tip.update) - addCompletion "cleanup $($app)" $PSCompletions.replace_content($PSCompletions.data.scoop.info.tip.cleanup) - addCompletion "hold $($app)" $PSCompletions.replace_content($PSCompletions.data.scoop.info.tip.hold) - addCompletion "unhold $($app)" $PSCompletions.replace_content($PSCompletions.data.scoop.info.tip.unhold) - addCompletion "prefix $($app)" $PSCompletions.replace_content($PSCompletions.data.scoop.info.tip.prefix) + $completions += returnCompletion "uninstall $($app)" $PSCompletions.replace_content($PSCompletions.data.scoop.info.tip.uninstall) + $completions += returnCompletion "update $($app)" $PSCompletions.replace_content($PSCompletions.data.scoop.info.tip.update) + $completions += returnCompletion "cleanup $($app)" $PSCompletions.replace_content($PSCompletions.data.scoop.info.tip.cleanup) + $completions += returnCompletion "hold $($app)" $PSCompletions.replace_content($PSCompletions.data.scoop.info.tip.hold) + $completions += returnCompletion "unhold $($app)" $PSCompletions.replace_content($PSCompletions.data.scoop.info.tip.unhold) + $completions += returnCompletion "prefix $($app)" $PSCompletions.replace_content($PSCompletions.data.scoop.info.tip.prefix) } } foreach ($_ in Get-ChildItem "$scoop_path\cache" -ErrorAction SilentlyContinue) { @@ -59,7 +59,7 @@ function handleCompletions([System.Collections.Generic.List[System.Object]]$comp $part = $_.Name -split "#" $path = $_.FullName $cache = $part[0..1] -join "#" - addCompletion "cache rm $($cache)" $PSCompletions.replace_content($PSCompletions.data.scoop.info.tip.cache.rm) + $completions += returnCompletion "cache rm $($cache)" $PSCompletions.replace_content($PSCompletions.data.scoop.info.tip.cache.rm) } } } diff --git a/completions/volta/guid.txt b/completions/volta/guid.txt index f93627ba..420d2569 100644 --- a/completions/volta/guid.txt +++ b/completions/volta/guid.txt @@ -1 +1 @@ -9818f788-3842-46f5-b942-d38284fc3dc6 +608aeb7c-e056-4d1e-a8e7-c57c06c6e934 diff --git a/completions/volta/hooks.ps1 b/completions/volta/hooks.ps1 index 76125cf5..e3515b58 100644 --- a/completions/volta/hooks.ps1 +++ b/completions/volta/hooks.ps1 @@ -1,16 +1,16 @@ -function handleCompletions([System.Collections.Generic.List[System.Object]]$completions) { - function addCompletion($name, $tip = ' ', $symbol = '') { +function handleCompletions($completions) { + function returnCompletion($name, $tip = ' ', $symbol = '') { $symbols = foreach ($c in ($symbol -split ' ')) { $PSCompletions.config."symbol_$($c)" } $symbols = $symbols -join '' $padSymbols = if ($symbols) { "$($PSCompletions.config.menu_between_item_and_symbol)$($symbols)" }else { '' } $cmd_arr = $name -split ' ' - $completions.Add(@{ - name = $name - ListItemText = "$($cmd_arr[-1])$($padSymbols)" - CompletionText = $cmd_arr[-1] - ToolTip = $tip - }) + @{ + name = $name + ListItemText = "$($cmd_arr[-1])$($padSymbols)" + CompletionText = $cmd_arr[-1] + ToolTip = $tip + } } $voltaBinDir = Split-Path (Get-Command volta).Source -Parent $toolsDir = "$(Split-Path $voltaBinDir -Parent)\tools\image" @@ -19,7 +19,7 @@ function handleCompletions([System.Collections.Generic.List[System.Object]]$comp foreach ($l in $list) { $versionList = Get-ChildItem "$toolsDir\$l" -Directory foreach ($v in $versionList) { - addCompletion "pin $l@$($v.BaseName)" "pin - $l@$($v.BaseName)" + $completions += returnCompletion "pin $l@$($v.BaseName)" "pin - $l@$($v.BaseName)" } } return $completions diff --git a/completions/wsl/guid.txt b/completions/wsl/guid.txt index 385f50a2..601cb960 100644 --- a/completions/wsl/guid.txt +++ b/completions/wsl/guid.txt @@ -1 +1 @@ -5b3de082-7993-491e-b588-885c520a4c93 +02738147-3be6-4967-a0cd-b5a4252ab4c8 diff --git a/completions/wsl/hooks.ps1 b/completions/wsl/hooks.ps1 index e34e3532..03a7c40a 100644 --- a/completions/wsl/hooks.ps1 +++ b/completions/wsl/hooks.ps1 @@ -1,17 +1,19 @@ -function handleCompletions([System.Collections.Generic.List[System.Object]]$completions) { - function addCompletion($name, $tip = ' ', $symbol = '') { +function handleCompletions($completions) { + $tempList = @() + function returnCompletion($name, $tip = ' ', $symbol = '') { $symbols = foreach ($c in ($symbol -split ' ')) { $PSCompletions.config."symbol_$($c)" } $symbols = $symbols -join '' $padSymbols = if ($symbols) { "$($PSCompletions.config.menu_between_item_and_symbol)$($symbols)" }else { '' } $cmd_arr = $name -split ' ' - $completions.Add(@{ - name = $name - ListItemText = "$($cmd_arr[-1])$($padSymbols)" - CompletionText = $cmd_arr[-1] - ToolTip = $tip - }) + @{ + name = $name + ListItemText = "$($cmd_arr[-1])$($padSymbols)" + CompletionText = $cmd_arr[-1] + ToolTip = $tip + } } + function CleanNul($data) { $res = [System.Collections.Generic.List[byte]]::new() foreach ($_ in [System.Text.Encoding]::UTF8.GetBytes($data)) { @@ -21,25 +23,24 @@ function handleCompletions([System.Collections.Generic.List[System.Object]]$comp return [System.Text.Encoding]::UTF8.GetString($res) } - $Distro_list = foreach ($_ in wsl -l -q) { CleanNul $_ } - foreach ($_ in $Distro_list) { - if ($_ -ne '') { - $Distro = $_ - addCompletion "~ -d $($Distro)" $PSCompletions.replace_content($PSCompletions.data.wsl.info.tip.'--distribution') - addCompletion "-d $($Distro)" $PSCompletions.replace_content($PSCompletions.data.wsl.info.tip.'--distribution') - addCompletion "~ --distribution $($Distro)" $PSCompletions.replace_content($PSCompletions.data.wsl.info.tip.'--distribution') - addCompletion "--distribution $($Distro)" $PSCompletions.replace_content($PSCompletions.data.wsl.info.tip.'--distribution') + foreach ($_ in wsl -l -q) { + $Distro = CleanNul $_ + if ($Distro -ne '') { + $tempList += returnCompletion "~ -d $($Distro)" $PSCompletions.replace_content($PSCompletions.data.wsl.info.tip.'--distribution') + $tempList += returnCompletion "-d $($Distro)" $PSCompletions.replace_content($PSCompletions.data.wsl.info.tip.'--distribution') + $tempList += returnCompletion "~ --distribution $($Distro)" $PSCompletions.replace_content($PSCompletions.data.wsl.info.tip.'--distribution') + $tempList += returnCompletion "--distribution $($Distro)" $PSCompletions.replace_content($PSCompletions.data.wsl.info.tip.'--distribution') - addCompletion "-s $($Distro)" $PSCompletions.replace_content($PSCompletions.data.wsl.info.tip.'--distribution') - addCompletion "--set-default $($Distro)" $PSCompletions.replace_content($PSCompletions.data.wsl.info.tip.'--set-default') + $tempList += returnCompletion "-s $($Distro)" $PSCompletions.replace_content($PSCompletions.data.wsl.info.tip.'--distribution') + $tempList += returnCompletion "--set-default $($Distro)" $PSCompletions.replace_content($PSCompletions.data.wsl.info.tip.'--set-default') - addCompletion "-t $($Distro)" $PSCompletions.replace_content($PSCompletions.data.wsl.info.tip.'--set-default') - addCompletion "--terminate $($Distro)" $PSCompletions.replace_content($PSCompletions.data.wsl.info.tip.'--terminate') + $tempList += returnCompletion "-t $($Distro)" $PSCompletions.replace_content($PSCompletions.data.wsl.info.tip.'--set-default') + $tempList += returnCompletion "--terminate $($Distro)" $PSCompletions.replace_content($PSCompletions.data.wsl.info.tip.'--terminate') - addCompletion "--unregister $($Distro)" $PSCompletions.replace_content($PSCompletions.data.wsl.info.tip.'--unregister') + $tempList += returnCompletion "--unregister $($Distro)" $PSCompletions.replace_content($PSCompletions.data.wsl.info.tip.'--unregister') - addCompletion "--export $($Distro)" $PSCompletions.replace_content($PSCompletions.data.wsl.info.tip.'--export') + $tempList += returnCompletion "--export $($Distro)" $PSCompletions.replace_content($PSCompletions.data.wsl.info.tip.'--export') } } - return $completions + return $tempList + $completions } diff --git a/completions/yarn/guid.txt b/completions/yarn/guid.txt index e670a26f..52572590 100644 --- a/completions/yarn/guid.txt +++ b/completions/yarn/guid.txt @@ -1 +1 @@ -7df13a4d-292a-4f88-b3c6-ea9b0c518fb2 +ba1615ff-13d1-4e03-82b3-152e4ab7b37c diff --git a/completions/yarn/hooks.ps1 b/completions/yarn/hooks.ps1 index 2f0691d2..36674a61 100644 --- a/completions/yarn/hooks.ps1 +++ b/completions/yarn/hooks.ps1 @@ -1,19 +1,19 @@ -function handleCompletions([System.Collections.Generic.List[System.Object]]$completions) { +function handleCompletions($completions) { if (!(Test-Path "package.json")) { return $completions } - $tempList = [System.Collections.Generic.List[System.Object]]@() - function addCompletion($name, $tip = ' ', $symbol = '') { + $tempList = @() + function returnCompletion($name, $tip = ' ', $symbol = '') { $symbols = foreach ($c in ($symbol -split ' ')) { $PSCompletions.config."symbol_$($c)" } $symbols = $symbols -join '' $padSymbols = if ($symbols) { "$($PSCompletions.config.menu_between_item_and_symbol)$($symbols)" }else { '' } $cmd_arr = $name -split ' ' - $tempList.Add(@{ - name = $name - ListItemText = "$($cmd_arr[-1])$($padSymbols)" - CompletionText = $cmd_arr[-1] - ToolTip = $tip - }) + @{ + name = $name + ListItemText = "$($cmd_arr[-1])$($padSymbols)" + CompletionText = $cmd_arr[-1] + ToolTip = $tip + } } $packageJson = $PSCompletions.ConvertFrom_JsonToHashtable((Get-Content "package.json" -Raw)) @@ -22,22 +22,21 @@ function handleCompletions([System.Collections.Generic.List[System.Object]]$comp $devDependencies = $packageJson.devDependencies if ($scripts) { foreach ($script in $scripts.Keys) { - addCompletion $script "package.json scripts:`n$($scripts.$script)" - addCompletion "run $script" "package.json scripts:`n$($scripts.$script)" + $tempList += returnCompletion "run $script" "package.json scripts:`n$($scripts.$script)" } } if ($dependencies) { foreach ($dependency in $dependencies.Keys) { - addCompletion "remove $dependency" "Remove dependency: $($dependency) ($($dependencies.$dependency))" + $tempList += returnCompletion "remove $dependency" "Remove dependency: $($dependency) ($($dependencies.$dependency))" - addCompletion "upgrade $dependency" "Current Version: $($dependencies.$dependency)" + $tempList += returnCompletion "upgrade $dependency" "Current Version: $($dependencies.$dependency)" } } if ($devDependencies) { foreach ($devDependency in $devDependencies.Keys) { - addCompletion "remove $devDependency" "Remove devDependency: $($devDependency) ($($devDependencies.$devDependency))" + $tempList += returnCompletion "remove $devDependency" "Remove devDependency: $($devDependency) ($($devDependencies.$devDependency))" - addCompletion "upgrade $devDependency" "Current Version: $($devDependencies.$devDependency)" + $tempList += returnCompletion "upgrade $devDependency" "Current Version: $($devDependencies.$devDependency)" } } return $tempList + $completions