---
source: lib/src/complete/nu.rs
expression: "complete_nu(&CompleteOptions\n{\n    usage_bin: \"usage\".to_string(), shell: \"nu\".to_string(), bin:\n    \"mycli\".to_string(), cache_key: Some(\"1.2.3\".to_string()), spec: None,\n    usage_cmd: Some(\"mycli complete --usage\".to_string()),\n    include_bash_completion_lib: false, source_file: None,\n})"
---
# @generated by usage-cli from usage spec
module _mycli_completions {
    def mycli_completer [spans: list<string>] {
        let spec_dir = ($env.XDG_CACHE_HOME? | default ($nu.home-dir? | default $nu.home-path? | path join ".cache") | path join "usage")
        if not ($spec_dir | path exists) {
            mkdir $spec_dir
            if $nu.os-info.family != "windows" { ^chmod 0700 $spec_dir }
        }
        let spec_file = ($spec_dir | path join $"usage__usage_spec_mycli_1_2_3.spec")
        if not ($spec_file | path exists) {
            glob ($spec_dir | path join "usage__usage_spec_mycli_*.spec") | each {|f| if ((ls $f | get 0.modified) < ((date now) - 30day)) { rm --force $f } } | ignore
            ^mycli complete --usage | collect | save $spec_file
        }

        (^usage complete-word -f $spec_file --shell nu -- ...$spans)
        | lines
        | each {|it| $it | split column "\t" | rename value description | into record }
    }

    @complete mycli_completer
    export extern mycli []
}


# if "usage" is not installed show an error
if (which usage | is-empty) {
    return (error make {
        msg: "Error: usage CLI not found. This is required for completions to work in mycli.",
        help: "See https://usage.jdx.dev for more information."
    })
}
use _mycli_completions *
