using namespace System.Management.Automation using namespace System.Management.Automation.Language Register-ArgumentCompleter -Native -CommandName 'wallswitch' -ScriptBlock { param($wordToComplete, $commandAst, $cursorPosition) $commandElements = $commandAst.CommandElements $command = @( 'wallswitch' 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) { 'wallswitch' { [CompletionResult]::new('-b', '-b', [CompletionResultType]::ParameterName, 'Set a minimum file size (in bytes) for searching image files') [CompletionResult]::new('--min_size', '--min_size', [CompletionResultType]::ParameterName, 'Set a minimum file size (in bytes) for searching image files') [CompletionResult]::new('-B', '-B ', [CompletionResultType]::ParameterName, 'Set a maximum file size (in bytes) for searching image files') [CompletionResult]::new('--max_size', '--max_size', [CompletionResultType]::ParameterName, 'Set a maximum file size (in bytes) for searching image files') [CompletionResult]::new('-g', '-g', [CompletionResultType]::ParameterName, 'Generate shell completions and exit the program') [CompletionResult]::new('--generate', '--generate', [CompletionResultType]::ParameterName, 'Generate shell completions and exit the program') [CompletionResult]::new('-d', '-d', [CompletionResultType]::ParameterName, 'Set the minimum dimension that the height and width must satisfy') [CompletionResult]::new('--min_dimension', '--min_dimension', [CompletionResultType]::ParameterName, 'Set the minimum dimension that the height and width must satisfy') [CompletionResult]::new('-D', '-D ', [CompletionResultType]::ParameterName, 'Set the maximum dimension that the height and width must satisfy') [CompletionResult]::new('--max_dimension', '--max_dimension', [CompletionResultType]::ParameterName, 'Set the maximum dimension that the height and width must satisfy') [CompletionResult]::new('-i', '-i', [CompletionResultType]::ParameterName, 'Set the interval (in seconds) between each wallpaper displayed') [CompletionResult]::new('--interval', '--interval', [CompletionResultType]::ParameterName, 'Set the interval (in seconds) between each wallpaper displayed') [CompletionResult]::new('-m', '-m', [CompletionResultType]::ParameterName, 'Set the number of monitors [default: 2]') [CompletionResult]::new('--monitor', '--monitor', [CompletionResultType]::ParameterName, 'Set the number of monitors [default: 2]') [CompletionResult]::new('-o', '-o', [CompletionResultType]::ParameterName, 'Inform monitor orientation: Horizontal (side-by-side) or Vertical (stacked)') [CompletionResult]::new('--orientation', '--orientation', [CompletionResultType]::ParameterName, 'Inform monitor orientation: Horizontal (side-by-side) or Vertical (stacked)') [CompletionResult]::new('-p', '-p', [CompletionResultType]::ParameterName, 'Set number of pictures (or images) per monitor [default: 1]') [CompletionResult]::new('--pictures_per_monitor', '--pictures_per_monitor', [CompletionResultType]::ParameterName, 'Set number of pictures (or images) per monitor [default: 1]') [CompletionResult]::new('-c', '-c', [CompletionResultType]::ParameterName, 'Read the configuration file and exit the program') [CompletionResult]::new('--config', '--config', [CompletionResultType]::ParameterName, 'Read the configuration file and exit the program') [CompletionResult]::new('-s', '-s', [CompletionResultType]::ParameterName, 'Sort the images found') [CompletionResult]::new('--sort', '--sort', [CompletionResultType]::ParameterName, 'Sort the images found') [CompletionResult]::new('-v', '-v', [CompletionResultType]::ParameterName, 'Show intermediate runtime messages') [CompletionResult]::new('--verbose', '--verbose', [CompletionResultType]::ParameterName, 'Show intermediate runtime messages') [CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')') [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--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 }