Name | failprint JSON |
Version |
1.0.5
JSON |
| download |
home_page | None |
Summary | Run a command, print its output only if it fails. |
upload_time | 2025-07-22 11:29:30 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | None |
keywords |
cli
failure
output
runner
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# failprint
[](https://github.com/pawamoy/failprint/actions?query=workflow%3Aci)
[](https://pawamoy.github.io/failprint/)
[](https://pypi.org/project/failprint/)
[](https://app.gitter.im/#/room/#failprint:gitter.im)
Run a command, print its output only if it fails.
Tired of searching the `quiet` options of your programs
to lighten up the output of your `make check` or `make lint` commands?
Tired of finding out that standard output and error are mixed up in some of them?
Simply run your command through `failprint`.
If it succeeds, nothing is printed.
If it fails, standard error is printed.
Plus other configuration goodies :wink:
## Example
You don't want to see output when the command succeeds.

The task runner [`duty`](https://github.com/pawamoy/duty) uses `failprint`,
allowing you to define tasks in Python and run them with minimalist and beautiful output:

## Requirements
failprint requires Python 3.8 or above.
<details>
<summary>To install Python 3.8, I recommend using <a href="https://github.com/pyenv/pyenv"><code>pyenv</code></a>.</summary>
```bash
# install pyenv
git clone https://github.com/pyenv/pyenv ~/.pyenv
# setup pyenv (you should also put these three lines in .bashrc or similar)
export PATH="${HOME}/.pyenv/bin:${PATH}"
export PYENV_ROOT="${HOME}/.pyenv"
eval "$(pyenv init -)"
# install Python 3.8.17
pyenv install 3.8.17
# make it available globally
pyenv global system 3.8.17
```
</details>
## Installation
```bash
pip install failprint
```
With [`uv`](https://docs.astral.sh/uv/):
```bash
uv tool install failprint
```
## Usage
```console
% poetry run failprint -h
usage: failprint [-h] [-c {stdout,stderr,both,none}] [-f {pretty,tap}] [-y | -Y] [-p | -P] [-q | -Q] [-s | -S] [-z | -Z] [-n NUMBER]
[-t TITLE]
COMMAND [COMMAND ...]
positional arguments:
COMMAND
optional arguments:
-h, --help show this help message and exit
-c {stdout,stderr,both,none}, --capture {stdout,stderr,both,none}
Which output to capture. Colors are supported with 'both' only, unless the command has a 'force color'
option.
-f {pretty,tap}, --format {pretty,tap}
Output format. Pass your own Jinja2 template as a string with '-f custom=TEMPLATE'. Available variables:
command, title (command or title passed with -t), code (exit status), success (boolean), failure (boolean),
number (command number passed with -n), output (command output), nofail (boolean), quiet (boolean), silent
(boolean). Available filters: indent (textwrap.indent).
-y, --pty Enable the use of a pseudo-terminal. PTY doesn't allow programs to use standard input.
-Y, --no-pty Disable the use of a pseudo-terminal. PTY doesn't allow programs to use standard input.
-p, --progress Print progress while running a command.
-P, --no-progress Don't print progress while running a command.
-q, --quiet Don't print the command output, even if it failed.
-Q, --no-quiet Print the command output when it fails.
-s, --silent Don't print anything.
-S, --no-silent Print output as usual.
-z, --zero, --nofail Don't fail. Always return a success (0) exit code.
-Z, --no-zero, --strict
Return the original exit code.
-n NUMBER, --number NUMBER
Command number. Useful for the 'tap' format.
-t TITLE, --title TITLE
Command title. Default is the command itself.
```
```python
from failprint import run
cmd = "echo hello"
exit_code = run(
cmd, # str, list of str, or Python callable
args=None, # args for callable
kwargs=None, # kwargs for callable
number=1, # command number, useful for tap format
capture=None, # stdout, stderr, both, none, True or False
title=None, # command title
fmt=None, # pretty, tap, or custom="MY_CUSTOM_FORMAT"
pty=False, # use a PTY
progress=True, # print the "progress" template before running the command
nofail=False, # always return zero
quiet=False, # don't print output when the command fails
silent=False, # don't print anything
)
```
Raw data
{
"_id": null,
"home_page": null,
"name": "failprint",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "cli, failure, output, runner",
"author": null,
"author_email": "=?utf-8?q?Timoth=C3=A9e_Mazzucotelli?= <dev@pawamoy.fr>",
"download_url": "https://files.pythonhosted.org/packages/d2/ef/fb334c2a8fc48ad5b13334ec1396f255d0b8da453b15d484be251c9e2e9f/failprint-1.0.5.tar.gz",
"platform": null,
"description": "# failprint\n\n[](https://github.com/pawamoy/failprint/actions?query=workflow%3Aci)\n[](https://pawamoy.github.io/failprint/)\n[](https://pypi.org/project/failprint/)\n[](https://app.gitter.im/#/room/#failprint:gitter.im)\n\nRun a command, print its output only if it fails.\n\nTired of searching the `quiet` options of your programs\nto lighten up the output of your `make check` or `make lint` commands?\n\nTired of finding out that standard output and error are mixed up in some of them?\n\nSimply run your command through `failprint`.\nIf it succeeds, nothing is printed.\nIf it fails, standard error is printed.\nPlus other configuration goodies :wink:\n\n## Example\n\nYou don't want to see output when the command succeeds.\n\n\n\nThe task runner [`duty`](https://github.com/pawamoy/duty) uses `failprint`,\nallowing you to define tasks in Python and run them with minimalist and beautiful output:\n\n\n\n## Requirements\n\nfailprint requires Python 3.8 or above.\n\n<details>\n<summary>To install Python 3.8, I recommend using <a href=\"https://github.com/pyenv/pyenv\"><code>pyenv</code></a>.</summary>\n\n```bash\n# install pyenv\ngit clone https://github.com/pyenv/pyenv ~/.pyenv\n\n# setup pyenv (you should also put these three lines in .bashrc or similar)\nexport PATH=\"${HOME}/.pyenv/bin:${PATH}\"\nexport PYENV_ROOT=\"${HOME}/.pyenv\"\neval \"$(pyenv init -)\"\n\n# install Python 3.8.17\npyenv install 3.8.17\n\n# make it available globally\npyenv global system 3.8.17\n```\n</details>\n\n## Installation\n\n```bash\npip install failprint\n```\n\nWith [`uv`](https://docs.astral.sh/uv/):\n\n```bash\nuv tool install failprint\n```\n\n## Usage\n\n```console\n% poetry run failprint -h\nusage: failprint [-h] [-c {stdout,stderr,both,none}] [-f {pretty,tap}] [-y | -Y] [-p | -P] [-q | -Q] [-s | -S] [-z | -Z] [-n NUMBER]\n [-t TITLE]\n COMMAND [COMMAND ...]\n\npositional arguments:\n COMMAND\n\noptional arguments:\n -h, --help show this help message and exit\n -c {stdout,stderr,both,none}, --capture {stdout,stderr,both,none}\n Which output to capture. Colors are supported with 'both' only, unless the command has a 'force color'\n option.\n -f {pretty,tap}, --format {pretty,tap}\n Output format. Pass your own Jinja2 template as a string with '-f custom=TEMPLATE'. Available variables:\n command, title (command or title passed with -t), code (exit status), success (boolean), failure (boolean),\n number (command number passed with -n), output (command output), nofail (boolean), quiet (boolean), silent\n (boolean). Available filters: indent (textwrap.indent).\n -y, --pty Enable the use of a pseudo-terminal. PTY doesn't allow programs to use standard input.\n -Y, --no-pty Disable the use of a pseudo-terminal. PTY doesn't allow programs to use standard input.\n -p, --progress Print progress while running a command.\n -P, --no-progress Don't print progress while running a command.\n -q, --quiet Don't print the command output, even if it failed.\n -Q, --no-quiet Print the command output when it fails.\n -s, --silent Don't print anything.\n -S, --no-silent Print output as usual.\n -z, --zero, --nofail Don't fail. Always return a success (0) exit code.\n -Z, --no-zero, --strict\n Return the original exit code.\n -n NUMBER, --number NUMBER\n Command number. Useful for the 'tap' format.\n -t TITLE, --title TITLE\n Command title. Default is the command itself.\n```\n\n```python\nfrom failprint import run\n\ncmd = \"echo hello\"\n\nexit_code = run(\n cmd, # str, list of str, or Python callable\n args=None, # args for callable\n kwargs=None, # kwargs for callable\n number=1, # command number, useful for tap format\n capture=None, # stdout, stderr, both, none, True or False\n title=None, # command title\n fmt=None, # pretty, tap, or custom=\"MY_CUSTOM_FORMAT\"\n pty=False, # use a PTY\n progress=True, # print the \"progress\" template before running the command\n nofail=False, # always return zero\n quiet=False, # don't print output when the command fails\n silent=False, # don't print anything\n)\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Run a command, print its output only if it fails.",
"version": "1.0.5",
"project_urls": {
"Changelog": "https://pawamoy.github.io/failprint/changelog",
"Discussions": "https://github.com/pawamoy/failprint/discussions",
"Documentation": "https://pawamoy.github.io/failprint",
"Funding": "https://github.com/sponsors/pawamoy",
"Gitter": "https://gitter.im/failprint/community",
"Homepage": "https://pawamoy.github.io/failprint",
"Issues": "https://github.com/pawamoy/failprint/issues",
"Repository": "https://github.com/pawamoy/failprint"
},
"split_keywords": [
"cli",
" failure",
" output",
" runner"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "96083c24a9fc1305cc415696e326209f841f3fce6c13aa9082bddd26b68d0623",
"md5": "7681b9e7dfa3d4aa7e6f1b990a067641",
"sha256": "62e9e972927a45ac41eb26c40cc3872e7303fd9e86a90c7622a064881f2d2b2b"
},
"downloads": -1,
"filename": "failprint-1.0.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7681b9e7dfa3d4aa7e6f1b990a067641",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 21404,
"upload_time": "2025-07-22T11:29:28",
"upload_time_iso_8601": "2025-07-22T11:29:28.898691Z",
"url": "https://files.pythonhosted.org/packages/96/08/3c24a9fc1305cc415696e326209f841f3fce6c13aa9082bddd26b68d0623/failprint-1.0.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "d2effb334c2a8fc48ad5b13334ec1396f255d0b8da453b15d484be251c9e2e9f",
"md5": "8db8d63bd0a1bbd1b7ea8036f3f4cceb",
"sha256": "f839cec1bf9eb94ca6685b2695a0946aabfe9059121a8edb774c98cf44858f52"
},
"downloads": -1,
"filename": "failprint-1.0.5.tar.gz",
"has_sig": false,
"md5_digest": "8db8d63bd0a1bbd1b7ea8036f3f4cceb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 47722,
"upload_time": "2025-07-22T11:29:30",
"upload_time_iso_8601": "2025-07-22T11:29:30.937050Z",
"url": "https://files.pythonhosted.org/packages/d2/ef/fb334c2a8fc48ad5b13334ec1396f255d0b8da453b15d484be251c9e2e9f/failprint-1.0.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-22 11:29:30",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "pawamoy",
"github_project": "failprint",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "failprint"
}