|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
-
- @('gutenberg', './gutenberg') | %{
- Register-ArgumentCompleter -Native -CommandName $_ -ScriptBlock {
- param($wordToComplete, $commandAst, $cursorPosition)
-
- $command = '_gutenberg'
- $commandAst.CommandElements |
- Select-Object -Skip 1 |
- %{
- switch ($_.ToString()) {
-
- 'gutenberg' {
- $command += '_gutenberg'
- break
- }
-
- 'init' {
- $command += '_init'
- break
- }
-
- 'build' {
- $command += '_build'
- break
- }
-
- 'serve' {
- $command += '_serve'
- break
- }
-
- 'help' {
- $command += '_help'
- break
- }
-
- default {
- break
- }
- }
- }
-
- $completions = @()
-
- switch ($command) {
-
- '_gutenberg' {
- $completions = @('init', 'build', 'serve', 'help', '-c', '-h', '-V', '--config', '--help', '--version')
- }
-
- '_gutenberg_init' {
- $completions = @('-h', '-V', '--help', '--version')
- }
-
- '_gutenberg_build' {
- $completions = @('-h', '-V', '-u', '--help', '--version', '--base-url')
- }
-
- '_gutenberg_serve' {
- $completions = @('-h', '-V', '-i', '-p', '--help', '--version', '--interface', '--port')
- }
-
- '_gutenberg_help' {
- $completions = @('-h', '-V', '--help', '--version')
- }
-
- }
-
- $completions |
- ?{ $_ -like "$wordToComplete*" } |
- Sort-Object |
- %{ New-Object System.Management.Automation.CompletionResult $_, $_, 'ParameterValue', $_ }
- }
- }
|