-
-
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
refactor(cmds): use new cmds #5659
Conversation
1b85ee2
to
cd337ac
Compare
acff1dd
to
1e8fcb1
Compare
d66114a
to
8c954ff
Compare
8c954ff
to
8f49a11
Compare
@Stebalien CI checks had passed, could u help me review it? |
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.
Generally looks good to me, but I have not followed the cmdslib growth that closely.
There's 2 thing that stood out to me, but I'm looking to @keks and/or @Stebalien for guidance here.
Everything else seems in line with the typical cmds upgrade pattern.
Run: func(req cmds.Request, res cmds.Response) { | ||
res.SetError(errors.New("Mount isn't compatible with Windows yet"), cmdkit.ErrNormal) | ||
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { | ||
return errors.New("Mount isn't compatible with Windows yet") |
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.
Mount isn't compatible with Windows yet
I'll fix this in a separate PR ;^)
2291c3e
to
47c87a6
Compare
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.
So, it turns out go-ipfs has no issues with Emit versus EmitOnce because, internally, we always assume responses are streams of objects. However, js-ipfs changes their API based on whether we use EmitOnce or Emit so we need to make sure to use EmitOnce where appropriate.
Historically, SetOutput
was equivalent to EmitOnce
when passed an object and Emit
when passed a channel. Now that we no longer have a SetOutput
function, we need to be careful.
(we should also improve the commands lib API so we don't have to deal with this issue but that's a separate issue).
vf, ok := v.(*ConfigField) | ||
if !ok { | ||
return nil, e.TypeErr(vf, v) | ||
return res.Emit(output) |
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.
Same, this needs to use EmitOnce
.
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.
@Stebalien I found a strange question, when I use cmds.EmitOnce(output)
here, it will fail to pass t0063-external.sh
testcase. After analyzing the t0063-external.sh
. I found that ipfs config key value
won't remove repo.lock
file successfully. However, ipfs config key value
won't print any error or panic.
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.
be67020
to
ea50cad
Compare
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.
will also need a rebase and will need to use your new cmdenv.GetConfigRoot
.
vf, ok := v.(*ConfigField) | ||
if !ok { | ||
return nil, e.TypeErr(vf, v) | ||
return res.Emit(output) |
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.
fea0cda
to
f7a5151
Compare
core/commands/mount_unix.go
Outdated
}, | ||
Encoders: cmds.EncoderMap{ | ||
cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, mounts *config.Mounts) error { | ||
fmt.Fprintf(w, "IPFS mounted at: %s\nIPNS mounted at: %s\n", mounts.IPFS, mounts.IPNS) |
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 put this in two separate Fprintf
s.
f7a5151
to
51b05c6
Compare
License: MIT Signed-off-by: Overbool <overbool.xu@gmail.com>
License: MIT Signed-off-by: Overbool <overbool.xu@gmail.com>
License: MIT Signed-off-by: Overbool <overbool.xu@gmail.com>
License: MIT Signed-off-by: Overbool <overbool.xu@gmail.com>
License: MIT Signed-off-by: Overbool <overbool.xu@gmail.com>
License: MIT Signed-off-by: Overbool <overbool.xu@gmail.com>
License: MIT Signed-off-by: Overbool <overbool.xu@gmail.com>
License: MIT Signed-off-by: Overbool <overbool.xu@gmail.com>
51b05c6
to
0afbafd
Compare
Refer: #5664
Use new cmds lib in diag, config, mount, log command.