Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

keygen output #4

Open
samlown opened this issue Mar 2, 2022 · 4 comments
Open

keygen output #4

samlown opened this issue Mar 2, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@samlown
Copy link
Contributor

samlown commented Mar 2, 2022

It might be a good idea to generate output for the gobl keygen command that indicates what files have been generated, and where.

Does it make sense to write message to STDERR incase STDOUT is being used to pipe a generated key (perhaps?) A -v tag for verbose output might be a good idea.

@samlown samlown added the enhancement New feature or request label Mar 2, 2022
@flimzy
Copy link
Contributor

flimzy commented Mar 3, 2022

I think this type of thing requires some thought, as there are several ways to do something like this.

For this particular feature, what probably makes sense to me is outputting helpful info to STDOUT except when STDOUT is being used as the output location of the key (in which case the helpful output isn't helpful anyway), or when quiet mode (i.e. --quiet?) is on (i.e for scripting purposes).

I expect there are output situations not covered by that, though.

@samlown
Copy link
Contributor Author

samlown commented Mar 3, 2022

I think for this application where STDOUT is likely to be used for data output its acceptable to use STDERR for all logging, as a rule. Sending to STDERR requires more effort, hence why it's not so common, but I don't think it's bad practice.

If a logging library is used, then it should be easy to add a --quiet option too.

@flimzy
Copy link
Contributor

flimzy commented Mar 4, 2022

The problem with sending non-errors to STDERR is it makes error handling/detection in scripts very cumbersome.

@samlown
Copy link
Contributor Author

samlown commented Mar 15, 2022

It occurred to me that perhaps an alternate solution would be to always generate JSON output and make sure that the exit status code is non-zero. If you're worried about script handling, this would solve the problem and provide a universal interface with comparable results in both CLI and HTTP.

Argument errors, i.e. stuff caught by cobra, should be sent to STDERR as this clearly reflects invalid usage and you wouldn't want those to be scriptable.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants