---
source: lib/src/complete/powershell.rs
expression: "complete_powershell(&CompleteOptions\n{\n    usage_bin: \"usage\".to_string(), shell: \"powershell\".to_string(), bin:\n    \"mycli\".to_string(), cache_key: None, spec:\n    Some(SPEC_KITCHEN_SINK.clone()), usage_cmd: None,\n    include_bash_completion_lib: false, source_file: None,\n})"
---
# @generated by usage-cli from usage spec

if (-not (Get-Command 'usage' -ErrorAction SilentlyContinue)) {
    Write-Warning "Error: usage CLI not found. This is required for completions to work in mycli."
    Write-Warning "See https://usage.jdx.dev for more information."
    return
}

Register-ArgumentCompleter -Native -CommandName 'mycli' -ScriptBlock {
    param($wordToComplete, $commandAst, $cursorPosition)

    $tmpDir = if ($env:TEMP) { $env:TEMP } else { [System.IO.Path]::GetTempPath() }
    $specFile = Join-Path $tmpDir "usage__usage_spec_mycli.kdl"

    'name mycli
bin mycli
source_code_link_template "https://github.com/jdx/mise/blob/main/src/cli/{{path}}.rs"
flag --flag1 help="flag1 description"
flag --flag2 help="flag2 description" {
    long_help #"""
flag2 long description

includes a code block:

    $ echo hello world
    hello world

    more code

Examples:

    # run with no arguments to use the interactive selector
    $ mise use

    # set the current version of node to 20.x in mise.toml of current directory
    # will write the fuzzy version (e.g.: 20)

some docs

    $ echo hello world
    hello world
"""#
}
flag --flag3 help="flag3 description" negate=--no-flag3
flag --with-default default="default value"
flag --shell {
    arg <shell> {
        choices bash zsh fish
    }
}
arg <arg1> help="arg1 description"
arg "[arg2]" help="arg2 description" required=#false default="default value" {
    choices choice1 choice2 choice3
}
arg <arg3> help="arg3 description" help_long="arg3 long description"
arg <argrest>… var=#true
arg "[with-default]" required=#false default="default value"
complete plugin run=#"""
echo "plugin-1
plugin-2
plugin-3"
"""#
cmd plugin {
    cmd install {
        long_help "install a plugin"
        flag "-g --global" global=#true
        flag "-d --dir" {
            arg <dir>
        }
        flag "-f --force" negate=--no-force
        arg <plugin>
        arg <version>
    }
}
' | Out-File -FilePath $specFile -Encoding utf8

    $words = $commandAst.CommandElements | ForEach-Object { $_.ToString() }
    if ($words.Count -lt 1) {
        $words = @('mycli')
    }

    $completions = & 'usage' complete-word --shell powershell -f "$specFile" -- @words $wordToComplete 2>$null

    if ($completions) {
        $completions | ForEach-Object {
            $parts = $_ -split "`t", 2
            $completion = $parts[0]
            $description = if ($parts.Count -gt 1) { $parts[1] } else { '' }

            [System.Management.Automation.CompletionResult]::new(
                $completion,
                $completion,
                'ParameterValue',
                $description
            )
        }
    }
}
