@cryptotaxi247 / kubo / commits / 15cd24a6d

commands: Renamed Response#Value to Response#Output

Matt Bell committed Nov 3, 2014 at 15:47 UTC 15cd24a6d19dceaf911aa128c706da6c6b691158
7 files changed +16 -16
core/commands2/add.go
+2 -2
@@ -53,10 +53,10 @@ var addCmd = &cmds.Command{
53 added[i] = Object{k.String(), nil}
54 }
55
56 - res.SetValue(&AddOutput{added})
56 + res.SetOutput(&AddOutput{added})
57 },
58 Format: func(res cmds.Response) (string, error) {
59 - v := res.Value().(*AddOutput).Added
59 + v := res.Output().(*AddOutput).Added
60 if len(v) == 1 {
61 return fmt.Sprintf("Added object: %s\n", v[0].Hash), nil
62 }
core/commands2/cat.go
+1 -1
@@ -34,6 +34,6 @@ var catCmd = &cmds.Command{
34 }
35
36 reader := io.MultiReader(readers...)
37 - res.SetValue(reader)
37 + res.SetOutput(reader)
38 },
39 }
core/commands2/commands.go
+2 -2
@@ -16,10 +16,10 @@ var commandsCmd = &cmds.Command{
16 Help: "TODO",
17 Run: func(res cmds.Response, req cmds.Request) {
18 root := outputCommand("ipfs", Root)
19 - res.SetValue(&root)
19 + res.SetOutput(&root)
20 },
21 Format: func(res cmds.Response) (string, error) {
22 - v := res.Value().(*Command)
22 + v := res.Output().(*Command)
23 return formatCommand(v, 0), nil
24 },
25 Type: &Command{},
core/commands2/log.go
+1 -1
@@ -21,7 +21,7 @@ var logCmd = &cmds.Command{
21 }
22
23 s := fmt.Sprintf("Changed log level of '%s' to '%s'", args[0], args[1])
24 - res.SetValue(&MessageOutput{s})
24 + res.SetOutput(&MessageOutput{s})
25 },
26 Format: MessageFormatter,
27 Type: &MessageOutput{},
core/commands2/ls.go
+2 -2
@@ -50,11 +50,11 @@ var lsCmd = &cmds.Command{
50 }
51 }
52
53 - res.SetValue(&LsOutput{output})
53 + res.SetOutput(&LsOutput{output})
54 },
55 Format: func(res cmds.Response) (string, error) {
56 s := ""
57 - output := res.Value().(*LsOutput).Objects
57 + output := res.Output().(*LsOutput).Objects
58
59 for _, object := range output {
60 if len(output) > 1 {
core/commands2/publish.go
+2 -2
@@ -56,13 +56,13 @@ var publishCmd = &cmds.Command{
56 return
57 }
58
59 - res.SetValue(&PublishOutput{
59 + res.SetOutput(&PublishOutput{
60 Name: u.Key(hash).String(),
61 Value: ref,
62 })
63 },
64 Format: func(res cmds.Response) (string, error) {
65 - v := res.Value().(*PublishOutput)
65 + v := res.Output().(*PublishOutput)
66 return fmt.Sprintf("Published name %s to %s\n", v.Name, v.Value), nil
67 },
68 Type: &PublishOutput{},
core/commands2/root.go
+6 -6
@@ -69,10 +69,10 @@ var rootSubcommands = map[string]*cmds.Command{
69 Run: func(res cmds.Response, req cmds.Request) {
70 v := &TestOutput{"hello, world", 1337}
71 log.Info("beep")
72 - res.SetValue(v)
72 + res.SetOutput(v)
73 },
74 Format: func(res cmds.Response) (string, error) {
75 - v := res.Value().(*TestOutput)
75 + v := res.Output().(*TestOutput)
76 s := fmt.Sprintf("Foo: %s\n", v.Foo)
77 s += fmt.Sprintf("Bar: %v\n", v.Bar)
78 return s, nil
@@ -82,7 +82,7 @@ var rootSubcommands = map[string]*cmds.Command{
82 "boop": &cmds.Command{
83 Run: func(res cmds.Response, req cmds.Request) {
84 v := strings.NewReader("hello, world")
85 - res.SetValue(v)
85 + res.SetOutput(v)
86 },
87 },
88 "warp": &cmds.Command{
@@ -93,7 +93,7 @@ var rootSubcommands = map[string]*cmds.Command{
93 threshold := 1.21
94
95 if power, found := req.Option("power"); found && power.(float64) >= threshold {
96 - res.SetValue(struct {
96 + res.SetOutput(struct {
97 Status string
98 Power float64
99 }{"Flux capacitor activated!", power.(float64)})
@@ -106,7 +106,7 @@ var rootSubcommands = map[string]*cmds.Command{
106 },
107 "args": &cmds.Command{
108 Run: func(res cmds.Response, req cmds.Request) {
109 - res.SetValue(req.Arguments())
109 + res.SetOutput(req.Arguments())
110 },
111 },
112 }
@@ -121,5 +121,5 @@ type MessageOutput struct {
121 }
122
123 func MessageFormatter(res cmds.Response) (string, error) {
124 - return res.Value().(*MessageOutput).Message, nil
124 + return res.Output().(*MessageOutput).Message, nil
125 }