Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shellcompletion complete should print to the command's stdout. #19

Open
bckohan opened this issue Feb 27, 2024 · 2 comments
Open

shellcompletion complete should print to the command's stdout. #19

bckohan opened this issue Feb 27, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@bckohan
Copy link
Member

bckohan commented Feb 27, 2024

This is tricky because we don't want to redirect stdout using contextlib because that will mess up debuggers which is a main reason to use complete.

@bckohan bckohan added the bug Something isn't working label Feb 27, 2024
@bckohan bckohan self-assigned this Feb 27, 2024
@bckohan bckohan added enhancement New feature or request and removed bug Something isn't working labels Feb 28, 2024
@bckohan
Copy link
Member Author

bckohan commented Feb 28, 2024

To make this work is definitely another patch situation. Typer sends the completions to click.echo which does take a stream as an argument, but theres no way to hook into Typer's use of the call. echo defaults to stdout, but it would be possible to patch the click._compat.get_text_stdout/err functions to do this...

Should click.echo (and typer.echo) use the command stdout/stderr streams when called within the command context? probably... we do have the context tools to make this work.

@bckohan
Copy link
Member Author

bckohan commented Nov 21, 2024

No monkeypatch required - just needed to redirect stdout and catch the system exit that upstream throws.

bckohan added a commit that referenced this issue Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant