twitchdev/twitch-cli

[Feature Request] Exit with non-zero status in case of errors

Closed this issue · 4 comments

Tell us about your feature request

I'd like to use twitch-cli for automated testing and there, I need the exit status of the twitch-cli command to determine if the test succeeded. This mainly concerns the event subcommand (maybe for the mock-api as well (?)).

Disclaimer

  • I agree
Xemdo commented

So exiting with non-zero status in the event of it not returning the excepted 2xx code for those mock endpoints?

So exiting with non-zero status in the event of it not returning the excepted 2xx code for those mock endpoints?

Yes, and when the client returns unexpected data (e.g. an invalid challenge). I'm mostly concerned about the event {retrigger, trigger, verify} subcommands. The event websocket and mock-api are secondary. There, I'd think that if any request/reconnect/... goes wrong, then this is logged, and once SIGINT is received, the process exits with a non-zero status - compared to immediately exiting, which is inconvenient for regular CLI usage.

Xemdo commented

I'm adding this in, but I wanted to make a note that all errors will print to stdout to make it consistent across the entire program. Different features present data in different ways for different reasons, and it would take a rework of most things to write it in a way that print errors to stdout.

For example, "twitch api get users" will return a non-zero error code (because it returned a 400) but it will still write the JSON output to stdout instead of stderr.

Xemdo commented

It should be added in the next public release! If you see anything missing reopen this issue or open another :)