using namespace System.Management.Automation
using namespace System.Management.Automation.Language
Register-ArgumentCompleter -Native -CommandName 'neomake' -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPosition)
$commandElements = $commandAst.CommandElements
$command = @(
'neomake'
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) {
'neomake' {
[CompletionResult]::new('-e', 'e', [CompletionResultType]::ParameterName, 'Enables experimental features.')
[CompletionResult]::new('--experimental', 'experimental', [CompletionResultType]::ParameterName, 'Enables experimental features.')
[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')
[CompletionResult]::new('man', 'man', [CompletionResultType]::ParameterValue, 'Renders the manual.')
[CompletionResult]::new('autocomplete', 'autocomplete', [CompletionResultType]::ParameterValue, 'Renders shell completion scripts.')
[CompletionResult]::new('workflow', 'workflow', [CompletionResultType]::ParameterValue, 'Workflow related subcommands.')
[CompletionResult]::new('plan', 'plan', [CompletionResultType]::ParameterValue, 'Creates an execution plan.')
[CompletionResult]::new('execute', 'execute', [CompletionResultType]::ParameterValue, 'Executes an execution plan.')
[CompletionResult]::new('describe', 'describe', [CompletionResultType]::ParameterValue, 'Describes which nodes are executed in which stages.')
[CompletionResult]::new('list', 'list', [CompletionResultType]::ParameterValue, 'Lists all available nodes.')
[CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)')
break
}
'neomake;man' {
[CompletionResult]::new('-o', 'o', [CompletionResultType]::ParameterName, 'o')
[CompletionResult]::new('--out', 'out', [CompletionResultType]::ParameterName, 'out')
[CompletionResult]::new('-f', 'f', [CompletionResultType]::ParameterName, 'f')
[CompletionResult]::new('--format', 'format', [CompletionResultType]::ParameterName, 'format')
[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
}
'neomake;autocomplete' {
[CompletionResult]::new('-o', 'o', [CompletionResultType]::ParameterName, 'o')
[CompletionResult]::new('--out', 'out', [CompletionResultType]::ParameterName, 'out')
[CompletionResult]::new('-s', 's', [CompletionResultType]::ParameterName, 's')
[CompletionResult]::new('--shell', 'shell', [CompletionResultType]::ParameterName, 'shell')
[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
}
'neomake;workflow' {
[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')
[CompletionResult]::new('init', 'init', [CompletionResultType]::ParameterValue, 'Initializes a new template workflow.')
[CompletionResult]::new('schema', 'schema', [CompletionResultType]::ParameterValue, 'Renders the workflow schema to STDOUT.')
[CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)')
break
}
'neomake;workflow;init' {
[CompletionResult]::new('-t', 't', [CompletionResultType]::ParameterName, 'The template to init with.')
[CompletionResult]::new('--template', 'template', [CompletionResultType]::ParameterName, 'The template to init with.')
[CompletionResult]::new('-o', 'o', [CompletionResultType]::ParameterName, 'The file to render the output to. "-" renders to STDOUT.')
[CompletionResult]::new('--output', 'output', [CompletionResultType]::ParameterName, 'The file to render the output to. "-" renders to STDOUT.')
[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
}
'neomake;workflow;schema' {
[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
}
'neomake;workflow;help' {
[CompletionResult]::new('init', 'init', [CompletionResultType]::ParameterValue, 'Initializes a new template workflow.')
[CompletionResult]::new('schema', 'schema', [CompletionResultType]::ParameterValue, 'Renders the workflow schema to STDOUT.')
[CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)')
break
}
'neomake;workflow;help;init' {
break
}
'neomake;workflow;help;schema' {
break
}
'neomake;workflow;help;help' {
break
}
'neomake;plan' {
[CompletionResult]::new('--workflow', 'workflow', [CompletionResultType]::ParameterName, 'The workflow file to use.')
[CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Adding a node to the plan.')
[CompletionResult]::new('--node', 'node', [CompletionResultType]::ParameterName, 'Adding a node to the plan.')
[CompletionResult]::new('-r', 'r', [CompletionResultType]::ParameterName, 'Adding a node to the plan.')
[CompletionResult]::new('--regex', 'regex', [CompletionResultType]::ParameterName, 'Adding a node to the plan.')
[CompletionResult]::new('-a', 'a', [CompletionResultType]::ParameterName, 'Specifies a value for handlebars placeholders.')
[CompletionResult]::new('--arg', 'arg', [CompletionResultType]::ParameterName, 'Specifies a value for handlebars placeholders.')
[CompletionResult]::new('-o', 'o', [CompletionResultType]::ParameterName, 'Specifies the output format.')
[CompletionResult]::new('--output', 'output', [CompletionResultType]::ParameterName, 'Specifies the output format.')
[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
}
'neomake;execute' {
[CompletionResult]::new('-f', 'f', [CompletionResultType]::ParameterName, 'The format of the execution plan.')
[CompletionResult]::new('--format', 'format', [CompletionResultType]::ParameterName, 'The format of the execution plan.')
[CompletionResult]::new('-w', 'w', [CompletionResultType]::ParameterName, 'Defines how many worker threads are created in the OS thread pool.')
[CompletionResult]::new('--workers', 'workers', [CompletionResultType]::ParameterName, 'Defines how many worker threads are created in the OS thread pool.')
[CompletionResult]::new('-p', 'p', [CompletionResultType]::ParameterName, 'The prefix for child process output that gets printed to STDOUT.')
[CompletionResult]::new('--prefix', 'prefix', [CompletionResultType]::ParameterName, 'The prefix for child process output that gets printed to STDOUT.')
[CompletionResult]::new('-s', 's', [CompletionResultType]::ParameterName, 'Disables any output to STDOUT. Useful for preventing leakage of secrets.')
[CompletionResult]::new('--silent', 'silent', [CompletionResultType]::ParameterName, 'Disables any output to STDOUT. Useful for preventing leakage of secrets.')
[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
}
'neomake;describe' {
[CompletionResult]::new('--workflow', 'workflow', [CompletionResultType]::ParameterName, 'The workflow file to use.')
[CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Adding a node.')
[CompletionResult]::new('--node', 'node', [CompletionResultType]::ParameterName, 'Adding a node.')
[CompletionResult]::new('-r', 'r', [CompletionResultType]::ParameterName, 'Adding a node to the plan.')
[CompletionResult]::new('--regex', 'regex', [CompletionResultType]::ParameterName, 'Adding a node to the plan.')
[CompletionResult]::new('-o', 'o', [CompletionResultType]::ParameterName, 'The output format.')
[CompletionResult]::new('--output', 'output', [CompletionResultType]::ParameterName, 'The output format.')
[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
}
'neomake;list' {
[CompletionResult]::new('--workflow', 'workflow', [CompletionResultType]::ParameterName, 'The workflow file to use.')
[CompletionResult]::new('-o', 'o', [CompletionResultType]::ParameterName, 'The output format.')
[CompletionResult]::new('--output', 'output', [CompletionResultType]::ParameterName, 'The output format.')
[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
}
'neomake;help' {
[CompletionResult]::new('man', 'man', [CompletionResultType]::ParameterValue, 'Renders the manual.')
[CompletionResult]::new('autocomplete', 'autocomplete', [CompletionResultType]::ParameterValue, 'Renders shell completion scripts.')
[CompletionResult]::new('workflow', 'workflow', [CompletionResultType]::ParameterValue, 'Workflow related subcommands.')
[CompletionResult]::new('plan', 'plan', [CompletionResultType]::ParameterValue, 'Creates an execution plan.')
[CompletionResult]::new('execute', 'execute', [CompletionResultType]::ParameterValue, 'Executes an execution plan.')
[CompletionResult]::new('describe', 'describe', [CompletionResultType]::ParameterValue, 'Describes which nodes are executed in which stages.')
[CompletionResult]::new('list', 'list', [CompletionResultType]::ParameterValue, 'Lists all available nodes.')
[CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)')
break
}
'neomake;help;man' {
break
}
'neomake;help;autocomplete' {
break
}
'neomake;help;workflow' {
[CompletionResult]::new('init', 'init', [CompletionResultType]::ParameterValue, 'Initializes a new template workflow.')
[CompletionResult]::new('schema', 'schema', [CompletionResultType]::ParameterValue, 'Renders the workflow schema to STDOUT.')
break
}
'neomake;help;workflow;init' {
break
}
'neomake;help;workflow;schema' {
break
}
'neomake;help;plan' {
break
}
'neomake;help;execute' {
break
}
'neomake;help;describe' {
break
}
'neomake;help;list' {
break
}
'neomake;help;help' {
break
}
})
$completions.Where{ $_.CompletionText -like "$wordToComplete*" } |
Sort-Object -Property ListItemText
}