-
-
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
commands/refs: use new cmds #5679
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found another place where we should likely avoid using a channel but otherwise LGTM.
core/commands/refs.go
Outdated
if err != nil { | ||
res.SetError(err, cmdkit.ErrNormal) | ||
return | ||
return err | ||
} | ||
|
||
out := make(chan interface{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should likely drop this channel and go routine and use res.Emit directly for each value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to an Oddity with how parsing arguments from Stdin works when ever you have a command that can accept more than one argument from Stdin you must either call req.ParseBodyArgs()
before using req.Arguments
or iterate over them with req.BodyArgs()
, with the former being preferred for now. If you don't only the first argument will be read from Stdin.
You can test this my trying to pass two arguments via the command line to ipfs refs
and then try again via Stdin.
a35828a
to
e90b2f4
Compare
@overbool I would also like to get this p.r. in ASAP, let me know if you need any help with this. |
License: MIT Signed-off-by: Overbool <[email protected]>
License: MIT Signed-off-by: Overbool <[email protected]>
b858d06
to
bbbaf38
Compare
License: MIT Signed-off-by: Overbool <[email protected]>
bbbaf38
to
30c6dd9
Compare
License: MIT Signed-off-by: Overbool <[email protected]>
@kevina I had fixed them, could u help me review again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One bit but otherwise LGTM.
ctx := req.Context() | ||
n, err := req.InvocContext().GetNode() | ||
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { | ||
err := req.ParseBodyArgs() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move this down...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meh? Honestly, if we're going to do this up-front anyways, we might as well finish parsing the request as early as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can change this later if you'd like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really have a strong preference but we should at least try and be consistent about when we do this.
In any case fixing it now is a low priority.
Refer: #5664
License: MIT
Signed-off-by: Overbool [email protected]