twitchdev / twitch-cli

The official Twitch CLI to make developing on Twitch easier.
Apache License 2.0
604 stars 71 forks source link

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

Closed Nerixyz closed 1 year ago

Nerixyz commented 1 year ago

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

Xemdo commented 1 year ago

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

Nerixyz commented 1 year ago

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 1 year ago

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 1 year ago

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