---
source: lib/src/complete/zsh.rs
expression: "complete_zsh(&CompleteOptions\n{\n    usage_bin: \"usage\".to_string(), shell: \"zsh\".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})"
---
#compdef mycli
# @generated by usage-cli from usage spec
local curcontext="$curcontext"

_mycli() {
  emulate -L zsh
  typeset -A opt_args
  local curcontext="$curcontext" cache_policy

  if ! type -p usage &> /dev/null; then
      echo >&2
      echo "Error: usage CLI not found. This is required for completions to work in mycli." >&2
      echo "See https://usage.jdx.dev for more information." >&2
      return 1
  fi

  local spec_dir="${XDG_CACHE_HOME:-$HOME/.cache}/usage"
  [[ -d "$spec_dir" ]] || mkdir -p -m 700 "$spec_dir"
  local spec_file="$spec_dir/usage__usage_spec_mycli.spec"
  cat >| "$spec_file" <<'__USAGE_EOF__'
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>
    }
}
__USAGE_EOF__
  local -a values=() descs=() inserts=()
  local needs_menu=0 line
  while IFS= read -r line; do
    local -a parts=("${(@ps:\t:)line}")
    values+=("${parts[1]}")
    descs+=("${parts[2]}")
    inserts+=("${parts[3]}")
    [[ "${parts[3]}" == "'"* ]] && needs_menu=1
  done < <(command usage complete-word --shell zsh -f "$spec_file" -- "${(Q)words[@]}")
  (( needs_menu )) && compstate[insert]=menu
  if (( ${#inserts[@]} )); then
    local -a _usage_display=()
    local _usage_i _usage_max=0 _usage_v _usage_pad
    for _usage_v in "${values[@]}"; do
      (( ${#_usage_v} > _usage_max )) && _usage_max=${#_usage_v}
    done
    for ((_usage_i=1; _usage_i<=${#values[@]}; _usage_i++)); do
      if [[ -n "${descs[_usage_i]}" ]]; then
        _usage_pad=$(( _usage_max - ${#values[_usage_i]} ))
        _usage_display+=("${values[_usage_i]}${(l:_usage_pad:: :)}  -- ${descs[_usage_i]}")
      else
        _usage_display+=("${values[_usage_i]}")
      fi
    done
    compadd -l -d _usage_display -U -Q -S '' -a inserts
  fi
  return 0
}

if [ "$funcstack[1]" = "_mycli" ]; then
    _mycli "$@"
else
    compdef _mycli mycli
fi

# vim: noet ci pi sts=0 sw=4 ts=4
