dfinity / ic-wasm

A collection of libraries and tools for transforming Wasm canisters running on the Internet Computer
Apache License 2.0
34 stars 5 forks source link

Machine readable info #51

Open bitdivine opened 1 year ago

bitdivine commented 1 year ago

First off, thank you for a useful project.

I used to use wasm-nm (src) to get the symbol table from a Wasm file. It's basically the UNIX nm but for Wasms. Unfortunately wasm-nm is unmaintained and doesn't work on recent Wasm files that have new instructions.

Thankfully ic-wasm info also provides the list of exported functions and it works with recent wasms, so that is great. My only minor gripe is that the output is not very machine readable. I have to parse it with sed and if ever you change the format, those sed scripts might well break.

Would you be open to providing a machine readable output? For example, ic-wasm info --json so that the output can be parsed with jq?

If so, I would be happy to provide a PR to do this. I would propose to gather all the info collected here into a struct. On that struct I would have a to_string() method that provides output identical to the current output. I would then add the option of serializing that struct as JSON instead.

What do you think?

chenyan-dfinity commented 1 year ago

Sounds good to me. The current output is for human only, so we don't even need to keep the current format. Feel free to adjust the format as you see fit.