piotrmurach / tty-command

Execute shell commands with pretty output logging and capture stdout, stderr and exit status.
https://ttytoolkit.org
MIT License
400 stars 32 forks source link

feature request: built-in printer for command-only? #62

Closed jrochkind closed 3 years ago

jrochkind commented 3 years ago

The defualt printer prints command and stdout/stderr: "By default, when a command is run, the command and the output are printed to stdout using the :pretty printer."

:quiet will "only output actual command stdout and stderr", without the command.

:null and :progress will both print neither.

There is one thing missing from this matrix! I often want only the command printed out, without the stdout/stderr.

I could write my own custom printer, but is this common enough to justify including as a default? printer: :command maybe?

Or I might actually want the Running.. and Finished... lines, the Finished line too, just NOT the stdout/stderr! (Or actually, more advanced... I want to somehow capture stdout/stderr to ruby strings, but print out Running/Finished.... that is a more complicated usecase I'm not sure about how to do)

piotrmurach commented 3 years ago

Hi Jonathan,

What you suggest sounds reasonable. A printer that shows the command and the exit status only seems to complement the :quiet. I'm not sure how common a request it is though. It feels as though the stdout/stderr should be made available somehow in the case when the command fails. There is :only_output_on_error which seems more like what you need? It doesn't show any output unless the command fails.

jrochkind commented 3 years ago

In my case, the problem is certain commands that produce too much output, so I woudn't want to see it even on failure, it's just too much.

But that is starting to sound like more of a special edge case maybe. And I realized it might make more sense and work fine for me to just explicitly 2>1 >/dev/null my command, and use the pretty printer still.

So I'll just close this! Thanks for the response!