Skip to content

[Feature] Support installing completer with json format in PowerShell #9

@warappa

Description

@warappa

Currently, the powershell script that gets generated uses the default plain mode and therefore cannot use the description.

If the installer would default to json (see #8 ), then the existing CompletionResultItem.Description could be taken into account.

This is what I suggest:

Completer Snippet

...
# TODO: get from settings
$format = "json"

$completions = @()
if (Test-Path -PathType Leaf -Path ".\App.exe"){
    $completions = & ".\App.exe" completion complete --position $cursorPosition "$wordToComplete" --format $format
}
else{
    $completions = & "C:\<path>\App.exe" completion complete --position $cursorPosition "$wordToComplete" --format $format
}

$format -eq "json") {
    # parse json format
    $completions = $completions | ConvertFrom-Json
}

if ($completions) {
    if ($format -eq "json") {
        foreach ($completion in $completions) {
            [System.Management.Automation.CompletionResult]::new($completion.Value , $completion.Description, 'ParameterValue', $completion.Value)
        }
    } else {
        foreach ($completion in $completions) {
            [System.Management.Automation.CompletionResult]::new($completion , $completion, 'ParameterValue', $completion)
        }
    }
}
else {
    $null
}
....

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions