civo / cli

Our Command Line Interface (CLI) for interacting with your Civo resources
Apache License 2.0
178 stars 87 forks source link

Progress bars must go to stderr, not stdout #388

Open fernando-villalba opened 6 months ago

fernando-villalba commented 6 months ago

Issue

Progress bars should not be going to stdout, they need to go to stdout

How to replicate

1. Run a command with the --wait flag and pipe the output to a file

civo bucket create --wait -o json test-bucket > test

2. Inspect the file we just created:

cat test

Output:

% cat test
{"access_key":"xx","id":"9076386c-eda9-4eab-a995-7ba1aa92d3a5","name":"test-bucket"}

Looks normal? Except that it isn't, for example try the following command:

jq -r .access_key < test

Output:

tempo-tutorial % jq -r .access_key < test
jq: parse error: Invalid numeric literal at line 1, column 3

That should no possible? Why is this command not working in this perfectly valid json?

Because of the non-printable characters

3. Inspect the file for non printable characters

cat -v test

output:

 % cat -v test 
^M^[[KCreating an Object Store with maxSize 500, called test-bucket... | ^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^M^[[KCreating an Object Store with maxSize 500, called test-bucket... / ^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^?^?^?^?^?^?^?
...

Aceptance Criteria

uzaxirr commented 1 month ago

@dipu989 if you wish to contribute you can pick this one.

dipu989 commented 1 month ago

@uzaxirr Thanks for recommending this, I will pick it up 🚀

dipu989 commented 1 month ago

@uzaxirr I’ll be picking these up after a week. If anyone else wants to take them on in the meantime, feel free! Otherwise, I'll resume once I'm back.

uzaxirr commented 1 month ago

@dipu989 will u be working on it?

dipu989 commented 1 month ago

@uzaxirr Yes, I have raised a PR for this just now. PR link Please review.