- Notifications
You must be signed in to change notification settings - Fork 395
/
Copy pathdotnet-suggest-shim.ps1
24 lines (21 loc) · 1.08 KB
/
dotnet-suggest-shim.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# dotnet suggest shell start
if (Get-Command"dotnet-suggest"-errorAction SilentlyContinue)
{
$availableToComplete= (dotnet-suggest list) |Out-String
$availableToCompleteArray=$availableToComplete.Split([Environment]::NewLine, [System.StringSplitOptions]::RemoveEmptyEntries)
Register-ArgumentCompleter-Native -CommandName $availableToCompleteArray-ScriptBlock {
param($wordToComplete,$commandAst,$cursorPosition)
$fullpath= (Get-Command$commandAst.CommandElements[0]).Source
$arguments=$commandAst.Extent.ToString().Replace('"','\"')
dotnet-suggest get -e $fullpath--position $cursorPosition--"$arguments"|ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_,$_,'ParameterValue',$_)
}
}
}
else
{
"Unable to provide System.CommandLine tab completion support unless the [dotnet-suggest] tool is first installed."
"See the following for tool installation: https://www.nuget.org/packages/dotnet-suggest"
}
$env:DOTNET_SUGGEST_SCRIPT_VERSION="1.0.2"
# dotnet suggest script end