-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ipfs --encoding=json ls
not returning JSON
#7050
Comments
Linking to a similar one #5594. I wonder if this an easy fix or there is more to it though. |
I believe the solution is to detect that (a) the output is text and (b) the target is a terminal in |
Even better, introduce a |
But @Stebalien , why do we have to detect anything, if I'm explicitally asking for It sounds like it should still use text when the target is not a terminal, but it should use whatever the --enc= flag says. |
The problem is that we're abusing PostRun. It's designed to post-process results on the client (read results from the response, re-emit them to the next response emitter). Take a look at the ping command. However, we're using it to write to the console. We should be using the text encoder but:
That's why I'm saying we should consider having some kind of |
Several open issues mention problems with interaction of the global `--encoding=` flag and the Encoders and PostRun fields of command structs. This branch contains experimental refactors that explore approaches to consistent command execution patterns across offline, online and http modes. Specific tickets: - ipfs/kubo#7050 json encoding for `ls` - ipfs/kubo#1121 json encoding for `add` - ipfs/kubo#5594 json encoding for `stats bw` - ipfs#115 postrun design Possibly related: - ipfs/kubo#6640 global flags on subcommands Incomplete PRs: - ipfs/kubo#5620 json for 'stat'
Following the approach described in ipfs#115, define a new method signature on `Command` that supports full processing of the `Response` object when text encoding is requested. Add an encoding check and dispatch to DisplayCLI in local, http client, and http handler code paths. Unblocks resolution of `encoding` option processing in multiple go-ipfs issues. - ipfs/kubo#7050 json encoding for `ls` - ipfs/kubo#1121 json encoding for `add` - ipfs/kubo#5594 json encoding for `stats bw`
Following the approach described in ipfs#115, define a new method signature on `Command` that supports full processing of the `Response` object when text encoding is requested. Add an encoding check and dispatch to DisplayCLI in local, http client, and http handler code paths. Unblocks resolution of `encoding` option processing in multiple go-ipfs issues. - ipfs/kubo#7050 json encoding for `ls` - ipfs/kubo#1121 json encoding for `add` - ipfs/kubo#5594 json encoding for `stats bw`
Version information:
go-ipfs version: 0.4.23-6ce9a35
Repo version: 7
System version: amd64/darwin
Golang version: go1.13.7
Description:
The output of
ipfs --encoding=json ls
is expected to return JSON, as with other commands. Instead, the output is the same as without theencoding
parameter.Example:
Expected output similar to HTTP API call:
The text was updated successfully, but these errors were encountered: