Could you please update Register-PSFTeppScriptblock to support the Completion Result's List Item Text property in addition to the current Text & ToolTip properties and add a parameter to specify what property to filter the wordToComplete on? i.e.
Register-PSFTeppScriptblock -Name Test.Human -ScriptBlock {
$Humans | Select-PSFObject 'ID as Text', 'Name as ListText', 'ToString() as ToolTip'
} -FilterOn ListText
Setup Code
class Human {
[int]$ID
[string]$Name
Human (
[int]$ID,
[string]$Name
) {
$this.ID = $ID
$this.Name = $Name
}
[string] ToString () {
return "$($this.Name) ($($this.ID))"
}
}
$HumanData = @(
@{
ID = 1
Name = 'John Doe'
},
@{
ID = 2
Name = 'Jane Doe'
},
@{
ID = 3
Name = 'Play Dough'
},
@{
ID = 4
Name = 'Pizza Dough'
}
)
$Humans = $HumanData | ForEach-Object { [Human]::New($_.ID, $_.Name) }
function Invoke-Human {
[CmdletBinding()]
param (
[Human]$Human
)
Write-PSFMessage -Level Host -Message "Using $Human"
}
Currently the list items are shown as the text and not the tooltip, so the list view relies on knowing the IDs instead of the names, or navigating through the options one at a time to see the name in the tooltip, which negates the user-friendliness:
Register-PSFTeppScriptblock -Name Test.Human -ScriptBlock { $Humans | Select-PSFObject 'ID as Text', 'Name as Tooltip' }
Register-PSFTeppArgumentCompleter -Name Test.Human -Parameter Human -Command Invoke-Human
Invoke-Human -Human <Ctrl+Space>
But if you specify the WordToComplete property and the ListItemText, you can autocomplete on the user-friendly names and show those names on the list view, while the selection renders down to the ID:
Could you please update
Register-PSFTeppScriptblock
to support the Completion Result's List Item Text property in addition to the currentText
&ToolTip
properties and add a parameter to specify what property to filter thewordToComplete
on? i.e.Setup Code
Currently the list items are shown as the text and not the tooltip, so the list view relies on knowing the IDs instead of the names, or navigating through the options one at a time to see the name in the tooltip, which negates the user-friendliness:
But if you specify the
WordToComplete
property and theListItemText
, you can autocomplete on the user-friendly names and show those names on the list view, while the selection renders down to the ID: