-
-
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
Add command does not support json encoding #1121
Comments
There is another issue with this that the
I have yet to tract down where the exact issue is though. |
Also pretty sure moving |
i wonder if we can remove the postrun thing entirely and get away with just getting fancy with the marshaler... I do a lot of hacky shit (tm) with the marshaler in core/commands/dht.go |
Ping |
what's next here? |
Basically we need to figure out what is the best approach to solve this issue. I played around with the idea @whyrusleeping mentioned but ran into concurrency issues and printing to stdout. I unfortunately accidently did a git reset and lost my changes, but the idea was to use a marshaller channel. This is the bit we talked about a while go: https://botbot.me/freenode/ipfs/2015-04-28/?msg=37740801&page=3 I'm not certain what the best approach is besides to not use the marshaller and simple correct (by applying the patch above or something similar) the issue of not resetting the encoding type. |
heres what we can do, we can keep track of progress on the daemon side (within the Run function) and pass all the keys back as objects over the channel marshaler in an object that looks something like: type AddUpdate struct {
Key string
Progress float64
} |
@travisperson you had not committed your changes ? |
Doesn't really matter too much. They were easy changes and I can rewrite On Thu, May 21, 2015, 2:21 AM Christian Couder [email protected]
|
has this been fixed? @travisperson |
For this to move forward, it would be a good idea to write sharness tests even if some of them fail. |
Agree with Chris wholeheartedly
|
This is not fixed yet. Has the revamp of the commands lib made the fix easier maybe ? |
No. See: ipfs/go-ipfs-cmds#115. |
This has been idle for two years, what's going on here? |
Hi @bqv . What's going on is that this is low priority because it is cosmetic and there are some workarounds, while the fix is not super simple and has been blocked on a number of refactors. But I agree that the case of Also related #7050 . |
Gotcha, ok |
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`
Currently the add command does not support JSON encoding.
This is due to setting the output to nil.
A fix to this is to detect the output format and skip this
PostRun
if the encoding is anything other thanText
.This however introduced another issue. All output is returned as JSON. If the
previoususerProvidedEncoding
is not set, we keep the JSON encoding.The reason we don't have a default encoding is due to using two different option keys, in the client.go file we use
cmds.EncShort
, while in the cli we useencoding
.However, there is another issue, since the
add
command does not use a marshaler, the check on line 240 will fail and switches to JSON.PostRun is used for progress, and at some point the Marshaler was removed.
I don't know the history of this file, so there might of been a good reason (not used?). Anyways without a Marshaler the original encoding will never get set back.
This is a start of a PR I want to open
I just want to get some feedback before making any commits.
/cc @jbenet @whyrusleeping @kyledrake
The text was updated successfully, but these errors were encountered: