diff --git a/completions/git/guid.txt b/completions/git/guid.txt index 2708b76..528f119 100644 --- a/completions/git/guid.txt +++ b/completions/git/guid.txt @@ -1 +1 @@ -211219ea-a694-4b13-bfa0-d772081d727a +ce23c252-fb81-4662-8cf9-f0ee3f1dac35 diff --git a/completions/git/hooks.ps1 b/completions/git/hooks.ps1 index 98fbc61..2038bfd 100644 --- a/completions/git/hooks.ps1 +++ b/completions/git/hooks.ps1 @@ -1,18 +1,6 @@ function handleCompletions($completions) { $tempList = @() - function returnCompletion($name, $tip = ' ', $symbol = '') { - $symbols = foreach ($c in ($symbol -split ' ')) { $PSCompletions.config.$c } - $symbols = $symbols -join '' - $padSymbols = if ($symbols) { "$($PSCompletions.config.between_item_and_symbol)$($symbols)" }else { '' } - $cmd_arr = $name -split ' ' - @{ - 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 = @{ HEAD = (git show HEAD --relative-date -q 2>$null) -join "`n" @@ -48,33 +36,33 @@ foreach ($_ in $branch_list) { $info = 'branch --- ' + $_ - $tempList += returnCompletion "switch $($_)" $info - $tempList += returnCompletion "branch $($_)" $info - $tempList += returnCompletion "merge $($_)" $info - $tempList += returnCompletion "diff $($_)" $info + $tempList += $PSCompletions.return_completion("switch $($_)", $info) + $tempList += $PSCompletions.return_completion("branch $($_)", $info) + $tempList += $PSCompletions.return_completion("merge $($_)", $info) + $tempList += $PSCompletions.return_completion("diff $($_)", $info) } foreach ($_ in $head_list.Keys) { $info = $head_list.$_ - $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 + $tempList += $PSCompletions.return_completion("rebase -i $($_)", $info) + $tempList += $PSCompletions.return_completion("rebase --interactive $($_)", $info) + $tempList += $PSCompletions.return_completion("diff $($_)", $info) + $tempList += $PSCompletions.return_completion("reset $($_)", $info) + $tempList += $PSCompletions.return_completion("reset --soft $($_)", $info) + $tempList += $PSCompletions.return_completion("reset --hard $($_)", $info) + $tempList += $PSCompletions.return_completion("reset --mixed $($_)", $info) + $tempList += $PSCompletions.return_completion("show $($_)", $info) } foreach ($_ in $branch_head_list) { $info = if ($head_list.$_) { $head_list.$_ }else { 'branch --- ' + $_ } - $tempList += returnCompletion "checkout $($_)" $info + $tempList += $PSCompletions.return_completion("checkout $($_)", $info) } foreach ($_ in $remote_list) { $info = 'remote --- ' + $_ - $tempList += returnCompletion "push $($_)" $info - $tempList += returnCompletion "pull $($_)" $info - $tempList += returnCompletion "fetch $($_)" $info - $tempList += returnCompletion "remote rename $($_)" $info - $tempList += returnCompletion "remote rm $($_)" $info + $tempList += $PSCompletions.return_completion("push $($_)", $info) + $tempList += $PSCompletions.return_completion("pull $($_)", $info) + $tempList += $PSCompletions.return_completion("fetch $($_)", $info) + $tempList += $PSCompletions.return_completion("remote rename $($_)", $info) + $tempList += $PSCompletions.return_completion("remote rm $($_)", $info) } foreach ($_ in $commit_info) { $hash = $_[0] @@ -83,30 +71,30 @@ $commit = $_[3..($_.Length - 1)] $content = $date + "`n" + $author + "`n" + ($commit -join "`n") - $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 + $tempList += $PSCompletions.return_completion("commit -C $($hash)", $content) + $tempList += $PSCompletions.return_completion("rebase -i $($hash)", $content) + $tempList += $PSCompletions.return_completion("rebase --interactive $($hash)", $content) + $tempList += $PSCompletions.return_completion("checkout $($hash)", $content) + $tempList += $PSCompletions.return_completion("diff $($hash)", $content) + $tempList += $PSCompletions.return_completion("reset $($hash)", $content) + $tempList += $PSCompletions.return_completion("reset --soft $($hash)", $content) + $tempList += $PSCompletions.return_completion("reset --hard $($hash)", $content) + $tempList += $PSCompletions.return_completion("reset --mixed $($hash)", $content) + $tempList += $PSCompletions.return_completion("show $($hash)", $content) + $tempList += $PSCompletions.return_completion("revert $($hash)", $content) + $tempList += $PSCompletions.return_completion("commit $($hash)", $content) } foreach ($_ in $tag_list) { - $tempList += returnCompletion "tag -d $($_)" "tag --- $($_)" - $tempList += returnCompletion "tag -v $($_)" "tag --- $($_)" + $tempList += $PSCompletions.return_completion("tag -d $($_)", "tag --- $($_)") + $tempList += $PSCompletions.return_completion("tag -v $($_)", "tag --- $($_)") } foreach ($_ in git stash list --encoding=gbk 2>$null) { if ($_ -match 'stash@\{(\d+)\}') { $stashId = $matches[1] - $tempList += returnCompletion "stash show $stashId" $_ - $tempList += returnCompletion "stash pop $stashId" $_ - $tempList += returnCompletion "stash apply $stashId" $_ - $tempList += returnCompletion "stash drop $stashId" $_ + $tempList += $PSCompletions.return_completion("stash show $stashId", $_) + $tempList += $PSCompletions.return_completion("stash pop $stashId", $_) + $tempList += $PSCompletions.return_completion("stash apply $stashId", $_) + $tempList += $PSCompletions.return_completion("stash drop $stashId", $_) } } return $tempList + $completions diff --git a/completions/npm/guid.txt b/completions/npm/guid.txt index 5d6dea7..9dd0544 100644 --- a/completions/npm/guid.txt +++ b/completions/npm/guid.txt @@ -1 +1 @@ -abbbb6bb-8d49-42ef-a6db-5955ea851a82 +5ccd47af-196e-4008-ac4f-46686c388c6a diff --git a/completions/npm/hooks.ps1 b/completions/npm/hooks.ps1 index ffcf75f..80c56a1 100644 --- a/completions/npm/hooks.ps1 +++ b/completions/npm/hooks.ps1 @@ -1,19 +1,6 @@ function handleCompletions($completions) { if (!(Test-Path "package.json")) { return $completions } $tempList = @() - function returnCompletion($name, $tip = ' ', $symbol = '') { - $symbols = foreach ($c in ($symbol -split ' ')) { $PSCompletions.config.$c } - $symbols = $symbols -join '' - $padSymbols = if ($symbols) { "$($PSCompletions.config.between_item_and_symbol)$($symbols)" }else { '' } - $cmd_arr = $name -split ' ' - - @{ - name = $name - ListItemText = "$($cmd_arr[-1])$($padSymbols)" - CompletionText = $cmd_arr[-1] - ToolTip = $tip - } - } $packageJson = $PSCompletions.ConvertFrom_JsonToHashtable((Get-Content "package.json" -Raw)) $scripts = $packageJson.scripts @@ -21,19 +8,19 @@ $devDependencies = $packageJson.devDependencies if ($scripts) { foreach ($script in $scripts.Keys) { - $tempList += returnCompletion "run $script" "package.json scripts:`n$($scripts.$script)" + $tempList += $PSCompletions.return_completion("run $script", "package.json scripts:`n$($scripts.$script)") } } if ($dependencies) { foreach ($dependency in $dependencies.Keys) { - $tempList += returnCompletion "uninstall $dependency" "Uninstall dependency: $($dependency) ($($dependencies.$dependency))" - $tempList += returnCompletion "update $dependency" "Current Version: $($dependencies.$dependency)" + $tempList += $PSCompletions.return_completion("uninstall $dependency", "Uninstall dependency: $($dependency) ($($dependencies.$dependency))") + $tempList += $PSCompletions.return_completion("update $dependency", "Current Version: $($dependencies.$dependency)") } } if ($devDependencies) { foreach ($devDependency in $devDependencies.Keys) { - $tempList += returnCompletion "uninstall $devDependency" "Uninstall devDependency: $($devDependency) ($($devDependencies.$devDependency))" - $tempList += returnCompletion "update $devDependency" "Current Version: $($devDependencies.$devDependency)" + $tempList += $PSCompletions.return_completion("uninstall $devDependency", "Uninstall devDependency: $($devDependency) ($($devDependencies.$devDependency))") + $tempList += $PSCompletions.return_completion("update $devDependency", "Current Version: $($devDependencies.$devDependency)") } } return $tempList + $completions diff --git a/completions/pnpm/guid.txt b/completions/pnpm/guid.txt index aa54975..3163f7c 100644 --- a/completions/pnpm/guid.txt +++ b/completions/pnpm/guid.txt @@ -1 +1 @@ -c67113d3-c1d3-4b1f-bae3-a9a18e0daa82 +ce31e48b-522a-4c05-b3c5-e60b1ce4b62f diff --git a/completions/pnpm/hooks.ps1 b/completions/pnpm/hooks.ps1 index be4e540..f455fee 100644 --- a/completions/pnpm/hooks.ps1 +++ b/completions/pnpm/hooks.ps1 @@ -1,19 +1,6 @@ function handleCompletions($completions) { if (!(Test-Path "package.json")) { return $completions } $tempList = @() - function returnCompletion($name, $tip = ' ', $symbol = '') { - $symbols = foreach ($c in ($symbol -split ' ')) { $PSCompletions.config.$c } - $symbols = $symbols -join '' - $padSymbols = if ($symbols) { "$($PSCompletions.config.between_item_and_symbol)$($symbols)" }else { '' } - $cmd_arr = $name -split ' ' - - @{ - name = $name - ListItemText = "$($cmd_arr[-1])$($padSymbols)" - CompletionText = $cmd_arr[-1] - ToolTip = $tip - } - } $packageJson = $PSCompletions.ConvertFrom_JsonToHashtable((Get-Content "package.json" -Raw)) $scripts = $packageJson.scripts @@ -21,27 +8,27 @@ $devDependencies = $packageJson.devDependencies if ($scripts) { foreach ($script in $scripts.Keys) { - $tempList += returnCompletion "run $script" "package.json scripts:`n$($scripts.$script)" + $tempList += $PSCompletions.return_completion("run $script", "package.json scripts:`n$($scripts.$script)") } } if ($dependencies) { foreach ($dependency in $dependencies.Keys) { - $tempList += returnCompletion "rm $dependency" "Remove dependency: $($dependency) ($($dependencies.$dependency))" - $tempList += returnCompletion "remove $dependency" "Remove dependency: $($dependency) ($($dependencies.$dependency))" + $tempList += $PSCompletions.return_completion("rm $dependency", "Remove dependency: $($dependency) ($($dependencies.$dependency))") + $tempList += $PSCompletions.return_completion("remove $dependency", "Remove dependency: $($dependency) ($($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)" + $tempList += $PSCompletions.return_completion("update $dependency", "Current Version: $($dependencies.$dependency)") + $tempList += $PSCompletions.return_completion("up $dependency", "Current Version: $($dependencies.$dependency)") + $tempList += $PSCompletions.return_completion("upgrade $dependency", "Current Version: $($dependencies.$dependency)") } } if ($devDependencies) { foreach ($devDependency in $devDependencies.Keys) { - $tempList += returnCompletion "rm $devDependency" "Remove devDependency: $($devDependency) ($($devDependencies.$devDependency))" - $tempList += returnCompletion "remove $devDependency" "Remove devDependency: $($devDependency) ($($devDependencies.$devDependency))" + $tempList += $PSCompletions.return_completion("rm $devDependency", "Remove devDependency: $($devDependency) ($($devDependencies.$devDependency))") + $tempList += $PSCompletions.return_completion("remove $devDependency", "Remove devDependency: $($devDependency) ($($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)" + $tempList += $PSCompletions.return_completion("update $devDependency", "Current Version: $($devDependencies.$devDependency)") + $tempList += $PSCompletions.return_completion("up $devDependency", "Current Version: $($devDependencies.$devDependency)") + $tempList += $PSCompletions.return_completion("upgrade $devDependency", "Current Version: $($devDependencies.$devDependency)") } } return $tempList + $completions diff --git a/completions/psc/guid.txt b/completions/psc/guid.txt index 10e2379..3c5f569 100644 --- a/completions/psc/guid.txt +++ b/completions/psc/guid.txt @@ -1 +1 @@ -afb85eed-c01f-4117-81c6-8b4751e0f1cd +6b969328-ef06-44c4-b863-c3bb10aab7c7 diff --git a/completions/psc/hooks.ps1 b/completions/psc/hooks.ps1 index 861d20d..cdad016 100644 --- a/completions/psc/hooks.ps1 +++ b/completions/psc/hooks.ps1 @@ -1,81 +1,68 @@ function handleCompletions($completions) { - function returnCompletion($name, $tip = ' ', $symbol = '') { - $symbols = foreach ($c in ($symbol -split ' ')) { $PSCompletions.config.$c } - $symbols = $symbols -join '' - $padSymbols = if ($symbols) { "$($PSCompletions.config.between_item_and_symbol)$($symbols)" }else { '' } - $cmd_arr = $name -split ' ' - - @{ - name = $name - ListItemText = "$($cmd_arr[-1])$($padSymbols)" - CompletionText = $cmd_arr[-1] - ToolTip = $tip - } - } foreach ($completion in $PSCompletions.data.list) { - $completions += returnCompletion "rm $($completion)" $PSCompletions.replace_content($PSCompletions.info.rm.tip) + $completions += $PSCompletions.return_completion("rm $($completion)", $PSCompletions.replace_content($PSCompletions.info.rm.tip)) - $completions += returnCompletion "which $($completion)" $PSCompletions.replace_content($PSCompletions.info.which.tip) + $completions += $PSCompletions.return_completion("which $($completion)", $PSCompletions.replace_content($PSCompletions.info.which.tip)) - $completions += returnCompletion "alias add $($completion)" $PSCompletions.replace_content($PSCompletions.info.alias.add.tip) + $completions += $PSCompletions.return_completion("alias add $($completion)", $PSCompletions.replace_content($PSCompletions.info.alias.add.tip)) - $completions += returnCompletion "alias rm $($completion)" $PSCompletions.replace_content($PSCompletions.info.alias.rm.tip) 'SpaceTab' + $completions += $PSCompletions.return_completion("alias rm $($completion)", $PSCompletions.replace_content($PSCompletions.info.alias.rm.tip), 'SpaceTab') foreach ($alias in $PSCompletions.data.alias.$completion) { - $completions += returnCompletion "alias rm $($completion) $($alias)" $PSCompletions.replace_content($PSCompletions.info.alias.rm.tip_v) + $completions += $PSCompletions.return_completion("alias rm $($completion) $($alias)", $PSCompletions.replace_content($PSCompletions.info.alias.rm.tip_v)) } - $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) enable_tip" $PSCompletions.replace_content($PSCompletions.info.completion.enable_tip.tip) 'SpaceTab' + $completions += $PSCompletions.return_completion("completion $($completion)", $PSCompletions.replace_content($PSCompletions.info.completion.tip), 'SpaceTab') + $completions += $PSCompletions.return_completion("completion $($completion) language", $PSCompletions.replace_content($PSCompletions.info.completion.language.tip), 'SpaceTab') + $completions += $PSCompletions.return_completion("completion $($completion) enable_tip", $PSCompletions.replace_content($PSCompletions.info.completion.enable_tip.tip), 'SpaceTab') - $completions += returnCompletion "completion $($completion) enable_tip 1" $PSCompletions.replace_content($PSCompletions.info.completion.enable_tip.tip_v1) - $completions += returnCompletion "completion $($completion) enable_tip 0" $PSCompletions.replace_content($PSCompletions.info.completion.enable_tip.tip_v0) + $completions += $PSCompletions.return_completion("completion $($completion) enable_tip 1", $PSCompletions.replace_content($PSCompletions.info.completion.enable_tip.tip_v1)) + $completions += $PSCompletions.return_completion("completion $($completion) enable_tip 0", $PSCompletions.replace_content($PSCompletions.info.completion.enable_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) { - $completions += returnCompletion "completion $($completion) language $($language)" $PSCompletions.replace_content($PSCompletions.info.completion.language.tip_v) + $completions += $PSCompletions.return_completion("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) { - $completions += returnCompletion "completion $($completion) $($c.name)" $tip 'SpaceTab' + $completions += $PSCompletions.return_completion("completion $($completion) $($c.name)", $tip, 'SpaceTab') foreach ($value in $c.values) { - $completions += returnCompletion "completion $($completion) $($c.name) $($value)" $PSCompletions.replace_content($PSCompletions.info.completion.tip_v) + $completions += $PSCompletions.return_completion("completion $($completion) $($c.name) $($value)", $PSCompletions.replace_content($PSCompletions.info.completion.tip_v)) } } else { - $completions += returnCompletion "completion $($completion) $($c.name)" $tip + $completions += $PSCompletions.return_completion("completion $($completion) $($c.name)", $tip) } $config_item = $c.name - $completions += returnCompletion "reset completion $($completion) $($config_item)" $PSCompletions.replace_content($PSCompletions.info.reset.completion.tip_v) + $completions += $PSCompletions.return_completion("reset completion $($completion) $($config_item)", $PSCompletions.replace_content($PSCompletions.info.reset.completion.tip_v)) } - $completions += returnCompletion "reset alias $($completion)" $PSCompletions.replace_content($PSCompletions.info.reset.alias.tip) + $completions += $PSCompletions.return_completion("reset alias $($completion)", $PSCompletions.replace_content($PSCompletions.info.reset.alias.tip)) $symbol = if ($json.config) { 'SpaceTab' }else { '' } - $completions += returnCompletion "reset completion $($completion)" $PSCompletions.replace_content($PSCompletions.info.reset.completion.tip) $symbol + $completions += $PSCompletions.return_completion("reset completion $($completion)", $PSCompletions.replace_content($PSCompletions.info.reset.completion.tip), $symbol) } foreach ($completion in $PSCompletions.list) { if ($completion -notin $PSCompletions.data.list) { - $completions += returnCompletion "add $($completion)" $PSCompletions.replace_content($PSCompletions.info.add.tip) + $completions += $PSCompletions.return_completion("add $($completion)", $PSCompletions.replace_content($PSCompletions.info.add.tip)) } } foreach ($completion in $PSCompletions.update) { - $completions += returnCompletion "update $($completion)" $PSCompletions.replace_content($PSCompletions.info.update.tip) + $completions += $PSCompletions.return_completion("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) { - $completions += returnCompletion "menu custom color $($item) $($color)" $PSCompletions.replace_content($PSCompletions.info.menu.custom.color.tip) + $completions += $PSCompletions.return_completion("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 f15d9b1..1f18280 100644 --- a/completions/scoop/guid.txt +++ b/completions/scoop/guid.txt @@ -1 +1 @@ -c76ec130-c04e-4612-a96c-060b101509b9 +c17945ee-2703-420c-be76-98252aecc3cd diff --git a/completions/scoop/hooks.ps1 b/completions/scoop/hooks.ps1 index 6b1a9e3..401f328 100644 --- a/completions/scoop/hooks.ps1 +++ b/completions/scoop/hooks.ps1 @@ -1,17 +1,4 @@ function handleCompletions($completions) { - function returnCompletion($name, $tip = ' ', $symbol = '') { - $symbols = foreach ($c in ($symbol -split ' ')) { $PSCompletions.config.$c } - $symbols = $symbols -join '' - $padSymbols = if ($symbols) { "$($PSCompletions.config.between_item_and_symbol)$($symbols)" }else { '' } - $cmd_arr = $name -split ' ' - - @{ - name = $name - ListItemText = "$($cmd_arr[-1])$($padSymbols)" - CompletionText = $cmd_arr[-1] - ToolTip = $tip - } - } if ($PSVersionTable.Platform -ne 'Unix') { try { @@ -35,22 +22,22 @@ } foreach ($_ in scoop bucket known) { $bucket = $_ - $completions += returnCompletion "bucket add $($bucket)" $PSCompletions.replace_content($PSCompletions.completions.scoop.info.tip.bucket.add) + $completions += $PSCompletions.return_completion("bucket add $($bucket)", $PSCompletions.replace_content($PSCompletions.completions.scoop.info.tip.bucket.add)) } foreach ($_ in Get-ChildItem "$scoop_path\buckets" 2>$null) { $bucket = $_.Name - $completions += returnCompletion "bucket rm $($bucket)" $PSCompletions.replace_content($PSCompletions.completions.scoop.info.tip.bucket.rm) + $completions += $PSCompletions.return_completion("bucket rm $($bucket)", $PSCompletions.replace_content($PSCompletions.completions.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 - $completions += returnCompletion "uninstall $($app)" $PSCompletions.replace_content($PSCompletions.completions.scoop.info.tip.uninstall) - $completions += returnCompletion "update $($app)" $PSCompletions.replace_content($PSCompletions.completions.scoop.info.tip.update) - $completions += returnCompletion "cleanup $($app)" $PSCompletions.replace_content($PSCompletions.completions.scoop.info.tip.cleanup) - $completions += returnCompletion "hold $($app)" $PSCompletions.replace_content($PSCompletions.completions.scoop.info.tip.hold) - $completions += returnCompletion "unhold $($app)" $PSCompletions.replace_content($PSCompletions.completions.scoop.info.tip.unhold) - $completions += returnCompletion "prefix $($app)" $PSCompletions.replace_content($PSCompletions.completions.scoop.info.tip.prefix) + $completions += $PSCompletions.return_completion("uninstall $($app)", $PSCompletions.replace_content($PSCompletions.completions.scoop.info.tip.uninstall)) + $completions += $PSCompletions.return_completion("update $($app)", $PSCompletions.replace_content($PSCompletions.completions.scoop.info.tip.update)) + $completions += $PSCompletions.return_completion("cleanup $($app)", $PSCompletions.replace_content($PSCompletions.completions.scoop.info.tip.cleanup)) + $completions += $PSCompletions.return_completion("hold $($app)", $PSCompletions.replace_content($PSCompletions.completions.scoop.info.tip.hold)) + $completions += $PSCompletions.return_completion("unhold $($app)", $PSCompletions.replace_content($PSCompletions.completions.scoop.info.tip.unhold)) + $completions += $PSCompletions.return_completion("prefix $($app)", $PSCompletions.replace_content($PSCompletions.completions.scoop.info.tip.prefix)) } } foreach ($_ in Get-ChildItem "$scoop_path\cache" -ErrorAction SilentlyContinue) { @@ -59,7 +46,7 @@ $part = $_.Name -split "#" $path = $_.FullName $cache = $part[0..1] -join "#" - $completions += returnCompletion "cache rm $($cache)" $PSCompletions.replace_content($PSCompletions.completions.scoop.info.tip.cache.rm) + $completions += $PSCompletions.return_completion("cache rm $($cache)", $PSCompletions.replace_content($PSCompletions.completions.scoop.info.tip.cache.rm)) } } } diff --git a/completions/volta/guid.txt b/completions/volta/guid.txt index 9c6471c..12e905a 100644 --- a/completions/volta/guid.txt +++ b/completions/volta/guid.txt @@ -1 +1 @@ -83c69190-138e-4014-acfa-f6614421d361 +1174d531-b883-4262-a8d3-2f62e03355ea diff --git a/completions/volta/hooks.ps1 b/completions/volta/hooks.ps1 index 6851567..e394343 100644 --- a/completions/volta/hooks.ps1 +++ b/completions/volta/hooks.ps1 @@ -1,17 +1,4 @@ function handleCompletions($completions) { - function returnCompletion($name, $tip = ' ', $symbol = '') { - $symbols = foreach ($c in ($symbol -split ' ')) { $PSCompletions.config.$c } - $symbols = $symbols -join '' - $padSymbols = if ($symbols) { "$($PSCompletions.config.between_item_and_symbol)$($symbols)" }else { '' } - $cmd_arr = $name -split ' ' - - @{ - 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" $list = @("node", "npm", "pnpm", "yarn") @@ -19,7 +6,7 @@ foreach ($l in $list) { $versionList = Get-ChildItem "$toolsDir\$l" -Directory foreach ($v in $versionList) { - $completions += returnCompletion "pin $l@$($v.BaseName)" "pin - $l@$($v.BaseName)" + $completions += $PSCompletions.return_completion("pin $l@$($v.BaseName)", "pin - $l@$($v.BaseName)") } } return $completions diff --git a/completions/wsl/guid.txt b/completions/wsl/guid.txt index df7bbe1..ca71ea9 100644 --- a/completions/wsl/guid.txt +++ b/completions/wsl/guid.txt @@ -1 +1 @@ -d0da7fbc-bf7f-4660-aaea-baa65ef1c7bc +78112921-5b2f-46a0-b123-c38cddafdeaa diff --git a/completions/wsl/hooks.ps1 b/completions/wsl/hooks.ps1 index 1898986..7cd9f2e 100644 --- a/completions/wsl/hooks.ps1 +++ b/completions/wsl/hooks.ps1 @@ -1,18 +1,5 @@ function handleCompletions($completions) { $tempList = @() - function returnCompletion($name, $tip = ' ', $symbol = '') { - $symbols = foreach ($c in ($symbol -split ' ')) { $PSCompletions.config.$c } - $symbols = $symbols -join '' - $padSymbols = if ($symbols) { "$($PSCompletions.config.between_item_and_symbol)$($symbols)" }else { '' } - $cmd_arr = $name -split ' ' - - @{ - name = $name - ListItemText = "$($cmd_arr[-1])$($padSymbols)" - CompletionText = $cmd_arr[-1] - ToolTip = $tip - } - } function CleanNul($data) { $res = [System.Collections.Generic.List[byte]]::new() @@ -26,20 +13,20 @@ foreach ($_ in wsl -l -q) { $Distro = CleanNul $_ if ($Distro -ne '') { - $tempList += returnCompletion "~ -d $($Distro)" $PSCompletions.replace_content($PSCompletions.completions.wsl.info.tip.'--distribution') - $tempList += returnCompletion "-d $($Distro)" $PSCompletions.replace_content($PSCompletions.completions.wsl.info.tip.'--distribution') - $tempList += returnCompletion "~ --distribution $($Distro)" $PSCompletions.replace_content($PSCompletions.completions.wsl.info.tip.'--distribution') - $tempList += returnCompletion "--distribution $($Distro)" $PSCompletions.replace_content($PSCompletions.completions.wsl.info.tip.'--distribution') + $tempList += $PSCompletions.return_completion("~ -d $($Distro)", $PSCompletions.replace_content($PSCompletions.completions.wsl.info.tip.'--distribution')) + $tempList += $PSCompletions.return_completion("-d $($Distro)", $PSCompletions.replace_content($PSCompletions.completions.wsl.info.tip.'--distribution')) + $tempList += $PSCompletions.return_completion("~ --distribution $($Distro)", $PSCompletions.replace_content($PSCompletions.completions.wsl.info.tip.'--distribution')) + $tempList += $PSCompletions.return_completion("--distribution $($Distro)", $PSCompletions.replace_content($PSCompletions.completions.wsl.info.tip.'--distribution')) - $tempList += returnCompletion "-s $($Distro)" $PSCompletions.replace_content($PSCompletions.completions.wsl.info.tip.'--distribution') - $tempList += returnCompletion "--set-default $($Distro)" $PSCompletions.replace_content($PSCompletions.completions.wsl.info.tip.'--set-default') + $tempList += $PSCompletions.return_completion("-s $($Distro)", $PSCompletions.replace_content($PSCompletions.completions.wsl.info.tip.'--distribution')) + $tempList += $PSCompletions.return_completion("--set-default $($Distro)", $PSCompletions.replace_content($PSCompletions.completions.wsl.info.tip.'--set-default')) - $tempList += returnCompletion "-t $($Distro)" $PSCompletions.replace_content($PSCompletions.completions.wsl.info.tip.'--set-default') - $tempList += returnCompletion "--terminate $($Distro)" $PSCompletions.replace_content($PSCompletions.completions.wsl.info.tip.'--terminate') + $tempList += $PSCompletions.return_completion("-t $($Distro)", $PSCompletions.replace_content($PSCompletions.completions.wsl.info.tip.'--set-default')) + $tempList += $PSCompletions.return_completion("--terminate $($Distro)", $PSCompletions.replace_content($PSCompletions.completions.wsl.info.tip.'--terminate')) - $tempList += returnCompletion "--unregister $($Distro)" $PSCompletions.replace_content($PSCompletions.completions.wsl.info.tip.'--unregister') + $tempList += $PSCompletions.return_completion("--unregister $($Distro)", $PSCompletions.replace_content($PSCompletions.completions.wsl.info.tip.'--unregister')) - $tempList += returnCompletion "--export $($Distro)" $PSCompletions.replace_content($PSCompletions.completions.wsl.info.tip.'--export') + $tempList += $PSCompletions.return_completion("--export $($Distro)", $PSCompletions.replace_content($PSCompletions.completions.wsl.info.tip.'--export')) } } return $tempList + $completions diff --git a/completions/yarn/guid.txt b/completions/yarn/guid.txt index 4f0801b..9aab597 100644 --- a/completions/yarn/guid.txt +++ b/completions/yarn/guid.txt @@ -1 +1 @@ -9492c40d-1ae3-4cc2-95f1-7987524248d9 +bd81126d-1860-4146-840b-245da617002e diff --git a/completions/yarn/hooks.ps1 b/completions/yarn/hooks.ps1 index f102680..951a16b 100644 --- a/completions/yarn/hooks.ps1 +++ b/completions/yarn/hooks.ps1 @@ -2,19 +2,6 @@ if (!(Test-Path "package.json")) { return $completions } $tempList = @() - function returnCompletion($name, $tip = ' ', $symbol = '') { - $symbols = foreach ($c in ($symbol -split ' ')) { $PSCompletions.config.$c } - $symbols = $symbols -join '' - $padSymbols = if ($symbols) { "$($PSCompletions.config.between_item_and_symbol)$($symbols)" }else { '' } - $cmd_arr = $name -split ' ' - - @{ - name = $name - ListItemText = "$($cmd_arr[-1])$($padSymbols)" - CompletionText = $cmd_arr[-1] - ToolTip = $tip - } - } $packageJson = $PSCompletions.ConvertFrom_JsonToHashtable((Get-Content "package.json" -Raw)) $scripts = $packageJson.scripts @@ -22,21 +9,21 @@ $devDependencies = $packageJson.devDependencies if ($scripts) { foreach ($script in $scripts.Keys) { - $tempList += returnCompletion "run $script" "package.json scripts:`n$($scripts.$script)" + $tempList += $PSCompletions.return_completion("run $script", "package.json scripts:`n$($scripts.$script)") } } if ($dependencies) { foreach ($dependency in $dependencies.Keys) { - $tempList += returnCompletion "remove $dependency" "Remove dependency: $($dependency) ($($dependencies.$dependency))" + $tempList += $PSCompletions.return_completion("remove $dependency", "Remove dependency: $($dependency) ($($dependencies.$dependency))") - $tempList += returnCompletion "upgrade $dependency" "Current Version: $($dependencies.$dependency)" + $tempList += $PSCompletions.return_completion("upgrade $dependency", "Current Version: $($dependencies.$dependency)") } } if ($devDependencies) { foreach ($devDependency in $devDependencies.Keys) { - $tempList += returnCompletion "remove $devDependency" "Remove devDependency: $($devDependency) ($($devDependencies.$devDependency))" + $tempList += $PSCompletions.return_completion("remove $devDependency", "Remove devDependency: $($devDependency) ($($devDependencies.$devDependency))") - $tempList += returnCompletion "upgrade $devDependency" "Current Version: $($devDependencies.$devDependency)" + $tempList += $PSCompletions.return_completion("upgrade $devDependency", "Current Version: $($devDependencies.$devDependency)") } } return $tempList + $completions