Closed darksidemilk closed 1 month ago
[ArgumentCompleter(
{
param($Command, $Parameter, $WordToComplete, $CommandAst, $FakeBoundParams)
$r = (Get-FogHosts).Name
if ($WordToComplete) {
$r.Where{ $_ -match "^$WordToComplete" }
}
else {
$r
}
}
)]
Just a possible argument completer when using get-foghost downside is that it would then always run the full get-foghosts
Could cache the get-foghosts as a $script:hostsList script scoped variable, but that could change the flow with needed a -refresh switch or something when wanting to get an updated list. Granted, in 1.6 get-foghosts returns much faster.
Can use new test function for only doing autocomplete in 1.6 where reads are faster
Added, will be in next release
I believe I can add dynamic foghostname argument completers https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_functions_argument_completion?view=powershell-7.3#argumentcompleter-attribute
This could make many functions easier to use for new and experienced users alike. This same idea could be added to other fog object types as well. Just dynamic tab completions for everything would be awesome, but it will take some time to build out.