提交 15cd24a6 作者: Matt Bell 提交者: Juan Batiz-Benet

commands: Renamed Response#Value to Response#Output

上级 f1209d09
......@@ -53,10 +53,10 @@ var addCmd = &cmds.Command{
added[i] = Object{k.String(), nil}
}
res.SetValue(&AddOutput{added})
res.SetOutput(&AddOutput{added})
},
Format: func(res cmds.Response) (string, error) {
v := res.Value().(*AddOutput).Added
v := res.Output().(*AddOutput).Added
if len(v) == 1 {
return fmt.Sprintf("Added object: %s\n", v[0].Hash), nil
}
......
......@@ -34,6 +34,6 @@ var catCmd = &cmds.Command{
}
reader := io.MultiReader(readers...)
res.SetValue(reader)
res.SetOutput(reader)
},
}
......@@ -16,10 +16,10 @@ var commandsCmd = &cmds.Command{
Help: "TODO",
Run: func(res cmds.Response, req cmds.Request) {
root := outputCommand("ipfs", Root)
res.SetValue(&root)
res.SetOutput(&root)
},
Format: func(res cmds.Response) (string, error) {
v := res.Value().(*Command)
v := res.Output().(*Command)
return formatCommand(v, 0), nil
},
Type: &Command{},
......
......@@ -21,7 +21,7 @@ var logCmd = &cmds.Command{
}
s := fmt.Sprintf("Changed log level of '%s' to '%s'", args[0], args[1])
res.SetValue(&MessageOutput{s})
res.SetOutput(&MessageOutput{s})
},
Format: MessageFormatter,
Type: &MessageOutput{},
......
......@@ -50,11 +50,11 @@ var lsCmd = &cmds.Command{
}
}
res.SetValue(&LsOutput{output})
res.SetOutput(&LsOutput{output})
},
Format: func(res cmds.Response) (string, error) {
s := ""
output := res.Value().(*LsOutput).Objects
output := res.Output().(*LsOutput).Objects
for _, object := range output {
if len(output) > 1 {
......
......@@ -56,13 +56,13 @@ var publishCmd = &cmds.Command{
return
}
res.SetValue(&PublishOutput{
res.SetOutput(&PublishOutput{
Name: u.Key(hash).String(),
Value: ref,
})
},
Format: func(res cmds.Response) (string, error) {
v := res.Value().(*PublishOutput)
v := res.Output().(*PublishOutput)
return fmt.Sprintf("Published name %s to %s\n", v.Name, v.Value), nil
},
Type: &PublishOutput{},
......
......@@ -69,10 +69,10 @@ var rootSubcommands = map[string]*cmds.Command{
Run: func(res cmds.Response, req cmds.Request) {
v := &TestOutput{"hello, world", 1337}
log.Info("beep")
res.SetValue(v)
res.SetOutput(v)
},
Format: func(res cmds.Response) (string, error) {
v := res.Value().(*TestOutput)
v := res.Output().(*TestOutput)
s := fmt.Sprintf("Foo: %s\n", v.Foo)
s += fmt.Sprintf("Bar: %v\n", v.Bar)
return s, nil
......@@ -82,7 +82,7 @@ var rootSubcommands = map[string]*cmds.Command{
"boop": &cmds.Command{
Run: func(res cmds.Response, req cmds.Request) {
v := strings.NewReader("hello, world")
res.SetValue(v)
res.SetOutput(v)
},
},
"warp": &cmds.Command{
......@@ -93,7 +93,7 @@ var rootSubcommands = map[string]*cmds.Command{
threshold := 1.21
if power, found := req.Option("power"); found && power.(float64) >= threshold {
res.SetValue(struct {
res.SetOutput(struct {
Status string
Power float64
}{"Flux capacitor activated!", power.(float64)})
......@@ -106,7 +106,7 @@ var rootSubcommands = map[string]*cmds.Command{
},
"args": &cmds.Command{
Run: func(res cmds.Response, req cmds.Request) {
res.SetValue(req.Arguments())
res.SetOutput(req.Arguments())
},
},
}
......@@ -121,5 +121,5 @@ type MessageOutput struct {
}
func MessageFormatter(res cmds.Response) (string, error) {
return res.Value().(*MessageOutput).Message, nil
return res.Output().(*MessageOutput).Message, nil
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论