phrase / phrase-cli

CLI for the Phrase API
https://developers.phrase.com
MIT License
42 stars 6 forks source link

JSON output #137

Closed jimmymcpeter closed 5 months ago

jimmymcpeter commented 6 months ago

I'd love a way to consistently obtain JSON output from the CLI. npm does this with the json config on various commands. Below are a few examples of where I've encountered difficulty relying on the CLI output:

If my CLI is not the latest version, the output includes an update notification printed after every phrase command I run.

phrase keys exclude --project_id xyz --data 'abc123'
Please consider updating the Phrase Strings CLI client (2.15.0 < 2.19.3)
You can get the latest version from https://phrase.com/cli.
{
 "records_affected": 1174
}

If a request takes too long, the connection gets cut and your CDN returns a 504 along with HTML content. Your backend API server still processes the request.

phrase translations verify-collection --project_id xyz --data 'abc123'
Please consider updating the Phrase Strings CLI client (2.15.0 < 2.19.3)
You can get the latest version from https://phrase.com/cli.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The request could not be satisfied</TITLE>
</HEAD><BODY>
<H1>504 ERROR</H1>
<H2>The request could not be satisfied.</H2>
<HR noshade size="1px">
CloudFront attempted to establish a connection with the origin, but either the attempt failed or the origin closed the connection.
We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
<BR clear="all">
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
<BR clear="all">
<HR noshade size="1px">
<PRE>
Generated by cloudfront (CloudFront)
Request ID: idhere==
</PRE>
<ADDRESS>
</ADDRESS>
</BODY></HTML>

ERROR: 504 Gateway Timeout

I think just a way to turn off the update notification would be a nice option for now. I use this in GitHub Actions with the setup-cli action which requires the exact version be set (It doesn't support SemVer notation like actions/setup-node does) so I don't have an easy way to use the latest.

jablan commented 5 months ago

Hi @jimmymcpeter thanks for opening the issue!

Have you tried using batch (--batch or -B) option with the phrase cli? It should provide just that - parsable output without any warnings. (Of course, it's possible that it doesn't cover all possible places where phrase cli has output, please point us to particular use cases and we're address them.)

Hope this helps. We're address the setup-cli issue separately.

jimmymcpeter commented 5 months ago

Have you tried using batch (--batch or -B) option with the phrase cli?

I wasn't aware of this -- Thank you!