1 Commits

Author SHA1 Message Date
CodeAlex
de03ef97e8
fix(scripts): make doctor.py --help print usage without running diagnostics (#7433)
* fix(scripts): make doctor.py --help print usage without running diagnostics

scripts/doctor.py never parsed its arguments: `python scripts/doctor.py
--help` printed no usage and ran the whole diagnostic suite (subprocess
probes, config resolution, provider checks) and exited 0; any unrecognized
flag was silently ignored the same way. Closes #7386.

- Parse arguments with argparse.ArgumentParser in the __main__ entry point:
  --help prints usage and exits 0, unknown flags exit 2.
- The no-argument invocation used by `make doctor` is unchanged, and main()
  stays directly callable from the existing unit tests (they run in-process
  under pytest, whose argv must not reach argparse).
- Add backend/tests/test_doctor_script.py: offline subprocess cases for
  --help (usage, no diagnostics run), an unknown flag (exit 2), and the
  no-argument run (report footer present, exit 0 or 1).

* test(scripts): isolate doctor CLI subprocess checks

---------

Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
2026-10-25 09:50:48 +08:00