using namespace System.Management.Automation using namespace System.Management.Automation.Language Register-ArgumentCompleter -Native -CommandName 'triton-tui' -ScriptBlock { param($wordToComplete, $commandAst, $cursorPosition) $commandElements = $commandAst.CommandElements $command = @( 'triton-tui' for ($i = 1; $i -lt $commandElements.Count; $i++) { $element = $commandElements[$i] if ($element -isnot [StringConstantExpressionAst] -or $element.StringConstantType -ne [StringConstantType]::BareWord -or $element.Value.StartsWith('-') -or $element.Value -eq $wordToComplete) { break } $element.Value }) -join ';' $completions = @(switch ($command) { 'triton-tui' { [CompletionResult]::new('-i', '-i', [CompletionResultType]::ParameterName, 'File containing public input') [CompletionResult]::new('--input', '--input', [CompletionResultType]::ParameterName, 'File containing public input') [CompletionResult]::new('-n', '-n', [CompletionResultType]::ParameterName, 'JSON file containing all non-determinism') [CompletionResult]::new('--non-determinism', '--non-determinism', [CompletionResultType]::ParameterName, 'JSON file containing all non-determinism') [CompletionResult]::new('--initial-state', '--initial-state', [CompletionResultType]::ParameterName, 'JSON file containing entire initial state') [CompletionResult]::new('--interrupt-cycle', '--interrupt-cycle', [CompletionResultType]::ParameterName, 'The maximum number of cycles to run after any interaction, preventing a frozen TUI in infinite loops') [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help') [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help') [CompletionResult]::new('-V', '-V ', [CompletionResultType]::ParameterName, 'Print version') [CompletionResult]::new('--version', '--version', [CompletionResultType]::ParameterName, 'Print version') break } }) $completions.Where{ $_.CompletionText -like "$wordToComplete*" } | Sort-Object -Property ListItemText }