confio / decode_raw

A protobuf debugging tool or protoc --decode_raw on steroids.
Apache License 2.0
9 stars 2 forks source link

Simplify using decode_raw in bash pipelines #5

Open uranix opened 2 months ago

uranix commented 2 months ago

Thank you for the great tool, was very useful to extract data from raw protobuf captures without writing any code.

However, decode_raw is not very friendly with pipeline processing in bash: it always output data with terminal colors on, even if tool output is piped to another utility.

If it is possible, please add some "raw" flags, that suppress colorizing the output and data type hints - they are great for debugging, but complicate processing with tools like xxd -r -p (to convert hex to binary). For now it requires the following to get data for a bytes field:

$ decode_raw --full .7 < test.pb | cut -d ' ' -f 4 | sed -e 's/\x1b\[[0-9;]*m//g' | xxd -r -p > buffer.raw

It would be great to simplify that into

$ decode_raw --full --raw .7 < test.pb | xxd -r -p > buffer.raw

or even

$ decode_raw --full --raw .7 < test.pb > buffer.raw

However, I have no idea how --raw should work for several fields. Probably the tool can mimic jq -r

webmaster128 commented 2 months ago

Hey! Great to hear the tool is useful.

Please note this section from the README:

It does not intend to:

Provide stable outputs for scripting

That being said, we could introduce a --no-color option that just disables all colouring

uranix commented 2 months ago

I am sorry, took the fast path and did not read the README carefully.

Yes, --no-color would be just great. Still, I have a workaround, so I can live with current behavior.