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

Add docs for #180 #651

Merged
merged 3 commits into from
Sep 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions nox/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,16 @@ def run(
# Display coverage report even when tests fail.
session.run("coverage", "report")

If you pass ``silent=True``, you can capture the output of a command that would
otherwise be shown to the user. For example to get the current Git commit ID::

out = session.run(
"git", "rev-parse", "--short", "HEAD",
external=True, silent=True
)

print("Current Git commit is", out.strip())

:param env: A dictionary of environment variables to expose to the
command. By default, all environment variables are passed.
:type env: dict or None
Expand All @@ -330,6 +340,12 @@ def run(
them. Set to ``None`` to never send a kill signal.
Default: ``0.2``
:type terminate_timeout: float or None
:param stdout: Redirect standard output of the command into a file. Can't be
combined with *silent*.
:type stdout: file or file descriptor
:param stderr: Redirect standard output of the command into a file. Can't be
combined with *silent*.
:type stderr: file or file descriptor
"""
if not args:
raise ValueError("At least one argument required to run().")
Expand Down