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

added a new parameter for method capture(echo) #2697

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SertugF
Copy link

@SertugF SertugF commented Dec 9, 2022

Type of changes

  • Bug fix
  • New feature
  • Documentation / docstrings
  • Tests
  • Other

Checklist

  • I've run the latest black with default args on new code.
  • I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate.
  • I've added tests for new code.
  • I accept that @willmcgugan may be pedantic in the code review.

Description

Added echo parameter for capture method. If value of echo is true, text is captured and showed in the terminal. If value of echo is false, text is captured but not showed in the terminal. Fixed earlier test for new argument and added new test. Changed documentation for capture. #2338

@ssbarnea
Copy link
Contributor

ssbarnea commented Dec 20, 2022

@willmcgugan I do not think that requiring approval to even run CI is making rich very welcoming to new folks. There is the risk the might lose interest before even having the first successful contribution.

I am not usable to approve...

@@ -313,10 +313,10 @@ Note that when writing to a file you may want to explicitly set the ``width`` ar
Capturing output
----------------

There may be situations where you want to *capture* the output from a Console rather than writing it directly to the terminal. You can do this with the :meth:`~rich.console.Console.capture` method which returns a context manager. On exit from this context manager, call :meth:`~rich.console.Capture.get` to return the string that would have been written to the terminal. Here's an example::
There may be situations where you want to *capture* the output from a Console without writing it directly to the terminal. You can do this with the :meth:`~rich.console.Console.capture` method using echo parameter which returns a context manager. If echo value is set to True(default) text is captured and written to the terminal. When echo value is set to False text captured but not written to the terminal. On exit from this context manager, call :meth:`~rich.console.Capture.get` to return the string that would have been written to the terminal. Here's an example::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default should be False, given that this was the default before

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check #2338 "The capture method should have an echo parameter. When echo=True (the default) text should be captured and written to the terminal. When echo=False the text should be captured but not written to the terminal." @willmcgugan wants it true default.

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.

3 participants