If a powershell function is wrapping a python function, so long as no param block is specified, its possible to easily pass all arbitrary args through with $args:
Function scl-hython {
& "$pythonDir\python.exe" myscript.py --some-arg hython $args
}
However as soon as I specify a param block (with multiple optional non positional paramaters), extra arbitrary args are no longer allowed and you will get an error like this:
A positional parameter cannot be found that accepts argument
Is there a way to enable arbitrary args and explicit ones for the sake of autocompletion?
I should also clarify, I am using multiple non positional parameters that are optional, and this case doesn't seem to be covered in existing similar answers.
param(...)block per se that precludes of of$args, it is the transition from a simple to an advanced function, which happens in one or both of the following cases: a[CmdletBinding()]attribute is used (which only takes effect above aparam(...)block) and/or a[Parameter()]attribute is used (which you may also use with the C-style syntax for declaring parameters, though usingparam(...)consistently is generally preferable).param(...), you'll still be able to use$args- to refer to all remaining arguments - as long as you neither use the[CmdletBinding()]nor a per-parameter[Parameter()]attribute.