I have a function that makes use of the fzf cli utility, I use it to interactively select a object (by selecting a value that belongs to one its properties)
Function SelectFZF-Object{
param(
[argumentcompletions('Name','BaseName','Extension','Parent','FullName','Title','Url')]
[parameter(ValueFromPipelineByPropertyName)]
[string]$DisplayProperty = "title",
[String]$Limit = "50",
[String]$mode = "-m",
[Parameter(ValueFromPipeline)]
$InputObect
)
begin{$collect = [System.Collections.Generic.List[object]]::new()}
process{$collect.Add($InputObect)}
end{$collect | ForEach-Object {$_."$DisplayProperty"} | fzf -e $mode | ForEach-Object {$collect | Where-Object $DisplayProperty -EQ $_}}
}
While it works fine for objects that have multiple properties, it does not work for simple scalar values, so I cant do the following:
"foo", "bar", "baz" | SelectFZF-Object
I am for example, expecting to get bar
returned to the output.
If I can just test the input object to find out if its a simple, flat or scalar value, then I can handle it accordingly, I have thus far not found anything though.