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.
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.
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 UNIXnm
but for Wasms. Unfortunatelywasm-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 withsed
and if ever you change the format, thosesed
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 withjq
?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?