_raptor() {
  local cur="${COMP_WORDS[COMP_CWORD]}" cmd="" opts="" i
  for ((i=1;i<COMP_CWORD;i++)); do
    case "${COMP_WORDS[i]}" in -*) ;; *) cmd="${COMP_WORDS[i]}"; break;; esac
  done
  if [[ -z "$cmd" ]]; then
    COMPREPLY=( $(compgen -W "compare completion config convert describe diff doctor estimate extract fev get gui help info mcp render report run set simulate spf step sweep tables validate --color --config --debug --dev-features --help --log-file --log-level --no-config --quiet --verbose --version" -- "$cur") ); return
  fi
  case "$cmd" in
    compare) opts="--analysis --format --help --importance --jobs --length --metric --runs --save-model --seed --set --set-file --stats-start --stop --timeout --weak-type" ;;
    completion) opts="--help" ;;
    config) opts="--help" ;;
    convert) opts="--allow-lossy --help --to" ;;
    describe) opts="--element --format --help" ;;
    diff) opts="--all --exit-code --format --help --ignore --match --only" ;;
    doctor) opts="--format --help" ;;
    estimate) opts="--format --help --length --runs" ;;
    extract) opts="--deps --format --help --hierarchy --output --pools --report-hazards --streams --treat" ;;
    fev) opts="--criticality --cycle --fail --format --help --log --phase --repair --script" ;;
    get) opts="--format --help" ;;
    gui) opts="--help --new --theme" ;;
    help) opts="--help" ;;
    info) opts="--element --format --help" ;;
    mcp) opts="" ;;
    render) opts="--help --highlight --level --max-px --no-annotations --output --theme --zoom-to" ;;
    report) opts="--format --help --report --workspace" ;;
    run) opts="--analysis --deps --format --help --hierarchy --importance --jobs --json --legacy-names --length --metrics --output --pools --progress --report --runs --save-model --seed --set --set-file --stats-start --stop --streams --strict --timeout --treat --weak-type --workspace" ;;
    set) opts="--backup --help --in-place --output --set-file" ;;
    simulate) opts="--analysis --deps --format --help --hierarchy --importance --jobs --json --legacy-names --length --metrics --output --pools --progress --report --runs --save-model --seed --set --set-file --stats-start --stop --streams --strict --timeout --treat --weak-type --workspace" ;;
    spf) opts="--criticality --format --help --output" ;;
    step) opts="--break --events --fine --format --help --run --until" ;;
    sweep) opts="--analysis --format --help --importance --jobs --length --metric --runs --save-model --seed --set --set-file --stats-start --stop --timeout --vary --weak-type" ;;
    tables) opts="--analysis --format --help --importance --jobs --length --list --output --run --runs --save-model --seed --set --set-file --stats-start --stop --table --timeout --weak-type" ;;
    validate) opts="--format --help --strict" ;;
  esac
  COMPREPLY=( $(compgen -f -W "$opts" -- "$cur") )
}
complete -o filenames -F _raptor raptor
