Skip to main content

Run a command, print its output only if it fails.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

failprint-0.5.1.tar.gz (11.7 kB view hashes)

Uploaded Source

Built Distribution

failprint-0.5.1-py3-none-any.whl (14.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page