Skip to main content

failprint

ci documentation pypi version

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

Some tools output a lot of things. You don't want to see it when the command succeeds.

Without failprint:

  • poetry run bandit -s B404 -r src/
  • poetry run black --check $(PY_SRC)

basic

With failprint:

  • poetry run failprint -- bandit -s B404 -r src/
  • poetry run failprint -- black --check $(PY_SRC)

failprint_fail

It's already better, no? Much more readable!

And when everything passes, it's even better:

failprint_success

Requirements

failprint requires Python 3.6 or above.

To install Python 3.6, I recommend using pyenv.
# 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.6
pyenv install 3.6.12

# make it available globally
pyenv global system 3.6.12

Installation

With pip:

python3.6 -m pip install failprint

With pipx:

python3.6 -m pip install --user pipx

pipx install --python python3.6 failprint

Usage

usage: failprint [-h] [-f {custom,pretty,tap}] [-o {stdout,stderr,combine}] [-n NUMBER] [-t TITLE] COMMAND [COMMAND ...]

positional arguments:
  COMMAND

optional arguments:
  -h, --help            show this help message and exit
  -f {custom,pretty,tap}, --format {custom,pretty,tap}
                        Output format. Pass your own Jinja2 template as a string with '-f custom=TEMPLATE'.
                        Available variables: title (command or title passed with -t), code (exit status), success (boolean), failure (boolean),
                        n (command number passed with -n), output (command output). Available filters: indent (textwrap.indent).
  -o {stdout,stderr,combine}, --output {stdout,stderr,combine}
                        Which output to use. Colors are supported with 'combine' only, unless the command has a 'force color' option.
  -n NUMBER, --number NUMBER
                        Command number. Useful for the 'tap' format.
  -t TITLE, --title TITLE
                        Command title. Default is the command itself.

Metadata

Release files for failprint 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for failprint 0.5.0
File Size Uploaded
failprint-0.5.0.tar.gz 11.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for failprint 0.5.0
File Interpreter ABI Platform
failprint-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 26.0 kB

Release files / failprint-0.5.0.tar.gz

Download URL failprint-0.5.0.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d239433535437686df2377dadcfdc75ff9b86157210b68aaa757feaa5885f613
BLAKE2b-256 checksum
How to use checksums
154d14059c86b0234ae0e4ac5fd2310dd58ad7afa29429db9faf3cd32d2dd3b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.0b2 CPython/3.8.5 Linux/5.8.12-arch1-1

Release files / failprint-0.5.0-py3-none-any.whl

Download URL failprint-0.5.0-py3-none-any.whl
Size 14.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a67dec84ee6cd3b6230f47625ebfa8bb0edf2f6e25b793c5d8663e7386abebdb
BLAKE2b-256 checksum
How to use checksums
a56a1a2b8adb9b7d8a20a84f5308f5e4ecc9d90f4276208816c774e5cc25747b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.0b2 CPython/3.8.5 Linux/5.8.12-arch1-1

Release history Release notifications | RSS feed

1.1.1

2 release files

1.1.0

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.11.1

2 release files

0.11.0

2 release files

0.10.0

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.1

2 release files

This release

0.5.0 This release

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page