using namespace System.Management.Automation using namespace System.Management.Automation.Language Register-ArgumentCompleter -Native -CommandName 'find-identical-files' -ScriptBlock { param($wordToComplete, $commandAst, $cursorPosition) $commandElements = $commandAst.CommandElements $command = @( 'find-identical-files' 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) { 'find-identical-files' { [CompletionResult]::new('-a', 'a', [CompletionResultType]::ParameterName, 'Choose the hash algorithm') [CompletionResult]::new('--algorithm', 'algorithm', [CompletionResultType]::ParameterName, 'Choose the hash algorithm') [CompletionResult]::new('-b', 'b', [CompletionResultType]::ParameterName, 'Set a minimum file size (in bytes) to search for identical files') [CompletionResult]::new('--min_size', 'min_size', [CompletionResultType]::ParameterName, 'Set a minimum file size (in bytes) to search for identical files') [CompletionResult]::new('-B', 'B ', [CompletionResultType]::ParameterName, 'Set a maximum file size (in bytes) to search for identical files') [CompletionResult]::new('--max_size', 'max_size', [CompletionResultType]::ParameterName, 'Set a maximum file size (in bytes) to search for identical files') [CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'Set the output directory for the CSV file (fif.csv)') [CompletionResult]::new('--csv_dir', 'csv_dir', [CompletionResultType]::ParameterName, 'Set the output directory for the CSV file (fif.csv)') [CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Set the minimum depth to search for identical files') [CompletionResult]::new('--min_depth', 'min_depth', [CompletionResultType]::ParameterName, 'Set the minimum depth to search for identical files') [CompletionResult]::new('-D', 'D ', [CompletionResultType]::ParameterName, 'Set the maximum depth to search for identical files') [CompletionResult]::new('--max_depth', 'max_depth', [CompletionResultType]::ParameterName, 'Set the maximum depth to search for identical files') [CompletionResult]::new('-f', 'f', [CompletionResultType]::ParameterName, 'Minimum frequency (number of identical files) to be filtered') [CompletionResult]::new('--min_frequency', 'min_frequency', [CompletionResultType]::ParameterName, 'Minimum frequency (number of identical files) to be filtered') [CompletionResult]::new('-F', 'F ', [CompletionResultType]::ParameterName, 'Maximum frequency (number of identical files) to be filtered') [CompletionResult]::new('--max_frequency', 'max_frequency', [CompletionResultType]::ParameterName, 'Maximum frequency (number of identical files) to be filtered') [CompletionResult]::new('-g', 'g', [CompletionResultType]::ParameterName, 'If provided, outputs the completion file for given shell') [CompletionResult]::new('--generate', 'generate', [CompletionResultType]::ParameterName, 'If provided, outputs the completion file for given shell') [CompletionResult]::new('-i', 'i', [CompletionResultType]::ParameterName, 'Set the input directory where to search for identical files [default: current directory]') [CompletionResult]::new('--input_dir', 'input_dir', [CompletionResultType]::ParameterName, 'Set the input directory where to search for identical files [default: current directory]') [CompletionResult]::new('-r', 'r', [CompletionResultType]::ParameterName, 'Print the result in the chosen format') [CompletionResult]::new('--result_format', 'result_format', [CompletionResultType]::ParameterName, 'Print the result in the chosen format') [CompletionResult]::new('-x', 'x', [CompletionResultType]::ParameterName, 'Set the output directory for the XLSX file (fif.xlsx)') [CompletionResult]::new('--xlsx_dir', 'xlsx_dir', [CompletionResultType]::ParameterName, 'Set the output directory for the XLSX file (fif.xlsx)') [CompletionResult]::new('-e', 'e', [CompletionResultType]::ParameterName, 'Prints extended path of identical files, otherwise relative path') [CompletionResult]::new('--extended_path', 'extended_path', [CompletionResultType]::ParameterName, 'Prints extended path of identical files, otherwise relative path') [CompletionResult]::new('-o', 'o', [CompletionResultType]::ParameterName, 'Omit hidden files (starts with ''.''), otherwise search all files') [CompletionResult]::new('--omit_hidden', 'omit_hidden', [CompletionResultType]::ParameterName, 'Omit hidden files (starts with ''.''), otherwise search all files') [CompletionResult]::new('-s', 's', [CompletionResultType]::ParameterName, 'Sort result by number of identical files, otherwise sort by file size') [CompletionResult]::new('--sort', 'sort', [CompletionResultType]::ParameterName, 'Sort result by number of identical files, otherwise sort by file size') [CompletionResult]::new('-t', 't', [CompletionResultType]::ParameterName, 'Show total execution time') [CompletionResult]::new('--time', 'time', [CompletionResultType]::ParameterName, 'Show total execution time') [CompletionResult]::new('-v', 'v', [CompletionResultType]::ParameterName, 'Show intermediate runtime messages') [CompletionResult]::new('--verbose', 'verbose', [CompletionResultType]::ParameterName, 'Show intermediate runtime messages') [CompletionResult]::new('-w', 'w', [CompletionResultType]::ParameterName, 'Wipe (Clear) the terminal screen before listing the identical files') [CompletionResult]::new('--wipe_terminal', 'wipe_terminal', [CompletionResultType]::ParameterName, 'Wipe (Clear) the terminal screen before listing the identical files') [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 }