#How to register-argumentcompleter for functions that don't have explicit parameter?

7 messages · Page 1 of 1 (latest)

glacial vessel
#

I guess [Parameter(ValueFromRemainingArguments)] can be a solution but I just wonder whether there's a direct one

function foo { echo @args } # no explicit parameter
Register-ArgumentCompleter -CommandName foo -ScriptBlock {} # ??
deep ledge
#

The -Native parameter.

glacial vessel
deep ledge
#

?

#
Register-ArgumentCompleter -CommandName foo -Native -ScriptBlock {
    param ( $wordToComplete, $commandAst, $cursorPosition )
    <# logic here #>
}
#

otherwise please share what you attempted

#

I'd expect to have a bad time with this fwiw. Functions have far better support for completion if you write a param block (or use dynamicparam)