darksidemilk / FogApi

Powershell Module for the Fog API
MIT License
5 stars 0 forks source link

Add foghost name tab completion #8

Closed darksidemilk closed 1 month ago

darksidemilk commented 1 year ago

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.

darksidemilk commented 12 months 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

darksidemilk commented 3 months ago

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.

darksidemilk commented 1 month ago

Can use new test function for only doing autocomplete in 1.6 where reads are faster

darksidemilk commented 1 month ago

Added, will be in next release