You might want to pipe the output of Spectacles to another command line tool, or redirect it to a file.
Because Spectacles uses the Python
logging library, it outputs all messages to stderr, not stdout.
This means if you try to redirect or pipe stdout to file (e.g.
spectacles sql > file.txt), the file will be empty, because stdout is also empty.
Instead, you need to redirect stderr to the output file. If you're using
zsh, you can use the handy
&> operator to redirect both stdout and stderr to a file. For example:
If you're not using a shell where
&> is supported, you can instead redirect stdout to the file, then redirect stderr to stdout:
This is also how you would pipe stderr, by first redirecting it to stdout. For example, you can use
tee so the output is displayed and redirected simultaneously. In this example, we're also ignoring stdout by sending it to
Spectacles adds color to some of the messages it outputs, which can show up as unwanted characters in places that don't support color, like plain text files. To disable color output, set the
NO_COLOR environment variable: