Skip to content

Route annotated command help through the application output stream - #1779

Open
AryanRG wants to merge 1 commit into
python-cmd2:mainfrom
AryanRG:fix/annotated-help-output
Open

AryanRG wants to merge 1 commit into
python-cmd2:mainfrom
AryanRG:fix/annotated-help-output

Conversation

@AryanRG

@AryanRG AryanRG commented Oct 17, 2026

Copy link
Copy Markdown

For commands decorated with @with_annotated, --help currently writes to process stdout instead of the cmd2 application output stream. For example, greet --help > help.txt leaves the requested file empty. The equivalent @with_argparser path already routes parser output through the application stream.

Wrap annotated argument parsing in the existing parser output_to(app.stdout) context. This covers both normal and unknown-argument parsing, including nested subcommands. Add regressions for application capture, overwrite redirection, append redirection, and no process-stdout leakage. The changelog notes the user-visible fix.

Local validation on macOS / Python 3.13.12:

  • 15 new regressions failed on the unchanged base and passed with the fix.
  • make check passed, including Ruff, ty, mypy, and documentation formatting.
  • make test: 2,023 passed, 3 skipped.
  • make docs-test passed.

Other operating systems and Python versions remain for hosted CI. AI assistance was used to investigate, implement, review, and test this change.

Closes #1776

@codecov

codecov Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.75%. Comparing base (93cfe81) to head (74cec46).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1779   +/-   ##
=======================================
  Coverage   99.75%   99.75%           
=======================================
  Files          23       23           
  Lines        6473     6474    +1     
=======================================
+ Hits         6457     6458    +1     
  Misses         16       16           
Flag Coverage Δ
unittests 99.75% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

with_annotated --help bypasses app.stdout and output redirection

1 participant