#compdef experts
_experts_node() {
  subs=(); flags=(); pos=()
  case $1 in
    '') subs=('api:Make an authenticated request to the Experts API' 'config:Show or save the API origin' 'courses:List published courses' 'events:List events' 'login:Sign in with your browser' 'logout:Revoke and remove the saved access token' 'stats:Platform stats and metrics' 'status:Check the API health endpoint' 'update:Check for and install a newer experts release' 'whoami:Show the signed-in profile'); flags=('--help:Show help' '-h:Show help' '--version:Show version' '-v:Show version'); pos=() ;;
    'api') subs=(); flags=('--method:HTTP method (default GET, or POST with a body)' '-X:HTTP method (default GET, or POST with a body)' '--field:Add a string field key=value (repeatable)' '-f:Add a string field key=value (repeatable)' '--raw-field:Add a typed field key=value: true/false/null/numbers, @file or @- (repeatable)' '-F:Add a typed field key=value: true/false/null/numbers, @file or @- (repeatable)' '--header:Add a request header "Name: value" (repeatable)' '-H:Add a request header "Name: value" (repeatable)' '--input:Read the request body from a file (- for stdin)' '--include:Print the status line and response headers' '-i:Print the status line and response headers' '--paginate:Fetch every page and print the merged list as one array' '--silent:Do not print the response body' '--help:Show help' '-h:Show help'); pos=() ;;
    'config') subs=(); flags=('--api-url:API origin to save' '--json:Print JSON output' '--help:Show help' '-h:Show help'); pos=() ;;
    'courses') subs=(); flags=('--search:Title search' '--limit:Maximum items per page (1-100)' '--page:Page number (1+)' '--json:Print the raw JSON response' '--help:Show help' '-h:Show help'); pos=() ;;
    'events') subs=(); flags=('--search:Title search' '--limit:Maximum items per page (1-100)' '--page:Page number (1+)' '--json:Print the raw JSON response' '--help:Show help' '-h:Show help'); pos=() ;;
    'login') subs=(); flags=('--token:Save an access token instead of using the browser. Use `--token -` to read it from stdin' '--browser:Open the sign-in page in a browser' '--no-browser:Only print the sign-in URL' '--help:Show help' '-h:Show help'); pos=() ;;
    'logout') subs=(); flags=('--yes:Do not ask for confirmation' '-y:Do not ask for confirmation' '--help:Show help' '-h:Show help'); pos=() ;;
    'stats') subs=('incidents:Public status-page incidents'); flags=('--help:Show help' '-h:Show help'); pos=() ;;
    'stats incidents') subs=(); flags=('--output:Output format' '-o:Output format' '--json:Same as --output json' '--help:Show help' '-h:Show help'); pos=() ;;
    'status') subs=(); flags=('--json:Print JSON output' '--help:Show help' '-h:Show help'); pos=() ;;
    'update') subs=(); flags=('--check:Only report whether an update is available' '--help:Show help' '-h:Show help'); pos=() ;;
    'whoami') subs=(); flags=('--json:Print the raw JSON profile' '--help:Show help' '-h:Show help'); pos=() ;;
  esac
}
_experts_values() {
  reply=()
  case "$1|$2" in
    'api|--method') reply=(); return 0 ;;
    'api|-X') reply=(); return 0 ;;
    'api|--field') reply=(); return 0 ;;
    'api|-f') reply=(); return 0 ;;
    'api|--raw-field') reply=(); return 0 ;;
    'api|-F') reply=(); return 0 ;;
    'api|--header') reply=(); return 0 ;;
    'api|-H') reply=(); return 0 ;;
    'api|--input') reply=(); return 0 ;;
    'config|--api-url') reply=(); return 0 ;;
    'courses|--search') reply=(); return 0 ;;
    'courses|--limit') reply=(); return 0 ;;
    'courses|--page') reply=(); return 0 ;;
    'events|--search') reply=(); return 0 ;;
    'events|--limit') reply=(); return 0 ;;
    'events|--page') reply=(); return 0 ;;
    'login|--token') reply=(); return 0 ;;
    'stats incidents|--output') reply=('table' 'json' 'csv'); return 0 ;;
    'stats incidents|-o') reply=('table' 'json' 'csv'); return 0 ;;
  esac
  return 1
}
_experts() {
  local p="" word i
  local -a subs flags pos reply
  # Walk the words typed so far down the command tree.
  for (( i = 2; i < CURRENT; i++ )); do
    word=${words[i]}
    [[ $word == -* ]] && continue
    _experts_node "$p"
    if (( ${subs[(I)${(b)word}:*]} )); then
      p="${p:+$p }$word"
    fi
  done
  if _experts_values "$p" "${words[CURRENT-1]}"; then
    (( $#reply )) && compadd -a reply
    return
  fi
  _experts_node "$p"
  if [[ ${words[CURRENT]} == -* ]]; then
    _describe 'option' flags
  else
    (( $#subs )) && _describe 'command' subs
    (( $#pos )) && compadd -a pos
  fi
}
# Autoloaded from fpath (packages): complete now. Sourced: register.
if [ "$funcstack[1]" = "_experts" ]; then
  _experts "$@"
else
  compdef _experts experts
fi
