Argument Completers

Beneath predictive intellisense, Argument Completers provide dynamic tab completion for parameter values while typing Powershell Cmdlets into the shell.

PowerShell provides completions on input to provide hints, enable discovery, and speed up input entry. Command names, parameter names, argument values and file paths can all be completed by pressing the <Tab> key.

Powershell also provides a MenuComplete function that's bound to <Ctrl+Space>. The MenuComplete function displays a list of matching completions below the command line.

The TcXaeMgmt Powershell module supports Argument Completers in many variations.

Device Address Completers

Typing Ctrl+Space while inserting the Parameters that specify the Address (here NetId, Route or Address), opens a list of registered routes of the Target System + the local system. These are the reachable routes.

PS> $s = new-TcSession -NetId 172.17.60.197.1.1
MYSYSTEM (192.168.0.2.1.1) REMOTESYSTEM (192.168.0.3.1.1)
PS> $s = new-TcSession -Route MYSYSTEM 
MYSYSTEM (192.168.0.2.1.1) REMOTESYSTEM (192.168.0.3.1.1)
PS> $s = new-TcSession -Address 192.168.0.2 
MYSYSTEM (192.168.0.2.1.1) REMOTESYSTEM (192.168.0.3.1.1)

Symbol Path Completers

The -Path Parameter describes the path to the symbol. If the target device system (with symbolic information) is already known by the Cmdlet (here by -Session parametrization), the argument completer can load the symbolic information from the target system and present the available Symbol Path options in the list.

If the target address is unavailable or not specified, no selection is proposed.

PS> $s = new-TcSession -NetId Local -port 851
PS> read-TcValue -session $s -Path '.tc2vBool'
'.tc2vBool' '.tc2vStruct' 'FB_Test' 'MAIN'
'.tc2vInt' '.tc2vStructArray' 'Global_Version' 'Slow'
'.tc2vIntArray' 'Constants'
'GVL' 'TwinCAT_SystemInfoVarList'
Argument Completers 1:

Depending on the size of the target symbolic information, downloading the symbolic information can take some time!

Using the -session parameter here instead of -netId and -port ensures that the Symbolic Information is loaded only one time and cached in the Session object!

DataType Name Completers

Here, the same session object is used for accessing the list of Data types.

PS> $s = new-TcSession -NetId Local -port 851
PS> get-TcDataType -session $s -name 'BIT'
'BIT' 'BOOL' 'BYTE'

Depending on the size of the target symbolic information, downloading the symbolic information can take some time!

Using the -session parameter here instead of -netId and -port ensures that the Symbolic Information is loaded only one time and cached in the Session object!


And many more …

Argument completers are available for many Cmdlet Parameters. Just try out <TAB> and <CTRL + TAB>.