rich-click icon indicating copy to clipboard operation
rich-click copied to clipboard

Feature request: provide modified `CliRunner`

Open ofek opened this issue 8 months ago • 1 comments

I'm working to replace our use of Click UI utilities with Rich equivalents. However, I ran into an issue today that prevents me from fully switching over. In particular I cannot yet use rich.prompt.Prompt & rich.prompt.Confirm in place of click.prompt & click.confirm, respectively.

During tests, the CliRunner that Click provides temporarily reassigns internal utilities in order to make test assertions work properly. Using the utilities provided by Rich aren't aware of what's happening so assertions break both from expected output and from checks within standard library functions like this line checking if stdin has been switched since the interpreter started.

I'm not sure if this is in scope but I think it should be as I view this library as the foundational project that allows Rich to provide all UI functionality while using Click only for CLI definitions/parsing 😄

ofek avatar Apr 10 '25 01:04 ofek

Interesting idea and good find. I think it can be considered in-scope.

It should be possible with something like, patching Prompt.ask with partialmethod(..., stream=stream) where stream = io.StringIO(input).

Not something I currently have bandwidth to prioritize but open to PRs.

dwreeves avatar Apr 14 '25 00:04 dwreeves