diff --git a/core/commands/active.go b/core/commands/active.go index 21e4b9c32bc4..777f590664ff 100644 --- a/core/commands/active.go +++ b/core/commands/active.go @@ -26,7 +26,7 @@ Lists running and recently run commands. }, Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { ctx := env.(*oldcmds.Context) - return res.Emit(ctx.ReqLog.Report()) + return cmds.EmitOnce(res, ctx.ReqLog.Report()) }, Options: []cmdkit.Option{ cmdkit.BoolOption("verbose", verboseOptionName, "Print extra information."), diff --git a/core/commands/config.go b/core/commands/config.go index 8e8c690b745b..5d39b24c8771 100644 --- a/core/commands/config.go +++ b/core/commands/config.go @@ -167,7 +167,7 @@ NOTE: For security reasons, this command will omit your private key. If you woul return err } - return res.Emit(&cfg) + return cmds.EmitOnce(res, &cfg) }, Encoders: cmds.EncoderMap{ cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *map[string]interface{}) error { @@ -319,7 +319,7 @@ var configProfileApplyCmd = &cmds.Command{ return err } - return res.Emit(&ConfigUpdateOutput{ + return cmds.EmitOnce(res, &ConfigUpdateOutput{ OldCfg: oldCfgMap, NewCfg: newCfgMap, }) diff --git a/core/commands/log.go b/core/commands/log.go index 49e24056c780..30e94922c498 100644 --- a/core/commands/log.go +++ b/core/commands/log.go @@ -63,7 +63,8 @@ the event log. s := fmt.Sprintf("Changed log level of '%s' to '%s'\n", subsystem, level) log.Info(s) - return res.Emit(&MessageOutput{s}) + + return cmds.EmitOnce(res, &MessageOutput{s}) }, Encoders: cmds.EncoderMap{ cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *MessageOutput) error { @@ -83,7 +84,7 @@ subsystems of a running daemon. `, }, Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { - return res.Emit(&stringList{logging.GetSubsystems()}) + return cmds.EmitOnce(res, &stringList{logging.GetSubsystems()}) }, Encoders: cmds.EncoderMap{ cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, list *stringList) error { diff --git a/core/commands/mount_unix.go b/core/commands/mount_unix.go index 64c35bca050a..4dd749e2ceff 100644 --- a/core/commands/mount_unix.go +++ b/core/commands/mount_unix.go @@ -14,6 +14,11 @@ import ( cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) +const ( + mountIPFSPathOptionName = "ipfs-path" + mountIPNSPathOptionName = "ipns-path" +) + var MountCmd = &cmds.Command{ Helptext: cmdkit.HelpText{ Tagline: "Mounts IPFS to the filesystem (read-only).", @@ -72,8 +77,8 @@ baz `, }, Options: []cmdkit.Option{ - cmdkit.StringOption("ipfs-path", "f", "The path where IPFS should be mounted."), - cmdkit.StringOption("ipns-path", "n", "The path where IPNS should be mounted."), + cmdkit.StringOption(mountIPFSPathOptionName, "f", "The path where IPFS should be mounted."), + cmdkit.StringOption(mountIPNSPathOptionName, "n", "The path where IPNS should be mounted."), }, Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { cfg, err := cmdenv.GetConfig(env) @@ -91,13 +96,13 @@ baz return err } - fsdir, found := req.Options["f"].(string) + fsdir, found := req.Options[mountIPFSPathOptionName].(string) if !found { fsdir = cfg.Mounts.IPFS // use default value } // get default mount points - nsdir, found := req.Options["n"].(string) + nsdir, found := req.Options[mountIPNSPathOptionName].(string) if !found { nsdir = cfg.Mounts.IPNS // NB: be sure to not redeclare! } @@ -110,7 +115,7 @@ baz var output config.Mounts output.IPFS = fsdir output.IPNS = nsdir - return res.Emit(&output) + return cmds.EmitOnce(res, &output) }, Type: config.Mounts{}, Encoders: cmds.EncoderMap{ diff --git a/core/commands/sysdiag.go b/core/commands/sysdiag.go index 55bc5a43e4bc..800bf4455ac0 100644 --- a/core/commands/sysdiag.go +++ b/core/commands/sysdiag.go @@ -54,7 +54,7 @@ Prints out information about your computer to aid in easier debugging. info["ipfs_version"] = version.CurrentVersionNumber info["ipfs_commit"] = version.CurrentCommit - return res.Emit(info) + return cmds.EmitOnce(res, info) }, }