#compdef experts
_experts() {
  if (( CURRENT == 2 )); then
    local -a commands
    commands=(
      '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'
    )
    _describe 'command' commands
    return
  fi
  local command=${words[2]}
  shift words
  (( CURRENT-- ))
  case $command in
    api)
      _arguments \
        '(--method -X)'{--method,-X}'[HTTP method (default GET, or POST with a body)]:method:' \
        '(--field -f)'{--field,-f}'[Add a string field key=value (repeatable)]:field:' \
        '(--raw-field -F)'{--raw-field,-F}'[Add a typed field key=value\: true/false/null/numbers, @file or @- (repeatable)]:raw-field:' \
        '(--header -H)'{--header,-H}'[Add a request header "Name\: value" (repeatable)]:header:' \
        '--input[Read the request body from a file (- for stdin)]:input:' \
        '(--include -i)'{--include,-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 -h)'{--help,-h}'[Show help]'
      ;;
    config)
      _arguments \
        '--api-url[API origin to save]:api-url:' \
        '--json[Print JSON output]' \
        '(--help -h)'{--help,-h}'[Show help]'
      ;;
    courses)
      _arguments \
        '--search[Title search]:search:' \
        '--limit[Maximum items per page (1-100)]:limit:' \
        '--page[Page number (1+)]:page:' \
        '--json[Print the raw JSON response]' \
        '(--help -h)'{--help,-h}'[Show help]'
      ;;
    events)
      _arguments \
        '--search[Title search]:search:' \
        '--limit[Maximum items per page (1-100)]:limit:' \
        '--page[Page number (1+)]:page:' \
        '--json[Print the raw JSON response]' \
        '(--help -h)'{--help,-h}'[Show help]'
      ;;
    login)
      _arguments \
        '--token[Save an access token instead of using the browser. Use `--token -` to read it from stdin]:token:' \
        '--browser[Open the sign-in page in a browser]' \
        '--no-browser[Only print the sign-in URL]' \
        '(--help -h)'{--help,-h}'[Show help]'
      ;;
    logout)
      _arguments \
        '(--yes -y)'{--yes,-y}'[Do not ask for confirmation]' \
        '(--help -h)'{--help,-h}'[Show help]'
      ;;
    stats)
      _arguments \
        '(--help -h)'{--help,-h}'[Show help]'
      ;;
    status)
      _arguments \
        '--json[Print JSON output]' \
        '(--help -h)'{--help,-h}'[Show help]'
      ;;
    update)
      _arguments \
        '--check[Only report whether an update is available]' \
        '(--help -h)'{--help,-h}'[Show help]'
      ;;
    whoami)
      _arguments \
        '--json[Print the raw JSON profile]' \
        '(--help -h)'{--help,-h}'[Show help]'
      ;;
  esac
}
# Autoloaded from fpath (packages): complete now. Sourced: register.
if [ "$funcstack[1]" = "_experts" ]; then
  _experts "$@"
else
  compdef _experts experts
fi
