bacalhau icon indicating copy to clipboard operation
bacalhau copied to clipboard

Separate cmd output to return job-id to stdout, and helper text to stderr

Open enricorotundo opened this issue 2 years ago • 6 comments

Currently

❯ bacalhau docker run ubuntu echo hello world
Job ID: 50422f95-ac90-4b1c-9ba6-39afb809ec53

To get the status of the job, run:
  bacalhau describe 50422f95-ac90-4b1c-9ba6-39afb809ec53

Needed

❯ bacalhau docker run ubuntu echo hello world
50422f95-ac90-4b1c-9ba6-39afb809ec53 # stdout
# stderr
To get the status of the job, run: # stderr
  bacalhau describe 50422f95-ac90-4b1c-9ba6-39afb809ec53 # stderr

This applies to:

  • docker run
  • probably create
  • what else?

Thread https://filecoinproject.slack.com/archives/C02RLM3JHUY/p1664961242037189

enricorotundo avatar Oct 05 '22 10:10 enricorotundo

Ftw I don’t agree with this - stderr should only be used when it’s an error?

aronchick avatar Oct 05 '22 13:10 aronchick

Outputting errors on stderr isn't a consistent thing, for example the output of HashiCorp's Vault CLI goes to stderr (e.g. see vault --help 2>/dev/null) where as Terraform goes to stdout. I remember running into this issue when doing some PowerShell on Windows a few years ago as PowerShell assumes that any tool which outputs to stderr must have failed rather than looking at the exit code.

Another example of a tool which mixes stdout & stderr is curl, which outputs the statistics to stderr so allowing users to safely redirect the output straight to a file.

wjam avatar Oct 05 '22 13:10 wjam

One problem with mixing stdout & stderr would potentially be having the two outputs interleaved on the user's terminal

wjam avatar Oct 05 '22 13:10 wjam

yeah, conventionally stderr is used for user facing status / info messages as well as error messages

consult the exit code for whether or not there was an error

lukemarsden avatar Oct 05 '22 14:10 lukemarsden

fixed in https://github.com/filecoin-project/bacalhau/commit/7fc27cf1527cbfc6a86d469b0eda6c97a42f89f4

lukemarsden avatar Oct 05 '22 14:10 lukemarsden

reverted, reopening pending discussion with @aronchick tomorrow

lukemarsden avatar Oct 05 '22 15:10 lukemarsden