ipfs / kubo

An IPFS implementation in Go
https://docs.ipfs.tech/how-to/command-line-quick-start/
Other
16.2k stars 3.03k forks source link

`ipfs stats bw` doesn't support --enc json #5594

Open MichaelMure opened 6 years ago

MichaelMure commented 6 years ago

Version information:

go-ipfs 0.4.17 and git master

Type:

Bug

Description:

All commands should support the --enc options. It doesn't work for ipfs stats bw I suppose because the result of the command is formatted in a PostRun instead of an Encoders.

overbool commented 6 years ago

@MichaelMure ipfs stats bw has a option --poll that supports uninterrupted output. Therefore, I think it's not easy to achieve this feature by using Encoders instead of PostRun.

Stebalien commented 6 years ago

This looks fixable, it's just a bit tricky. The encoder will be called once per item.

kevina commented 6 years ago

How important is this. Maybe this is something we should wait on until we fix the need for using PostRun in most cases otherwise we run into the same problems we had with ipfs ls --stream in particular it appears a header is outputted is some cases.

Stebalien commented 6 years ago

IMO, low priority. Most clients will just use HTTP directly.

lidel commented 2 years ago

Confirmed this is still a problem in 0.11.

Extracting specific value via ipfs stats bw --enc=json | jq <selector> would be easier and more future-proof than parsing text with sed/awk. If it makes fix easier, we don't need to support JSON output in --poll mode, fixing the default output would be more than enough.