@cryptotaxi247 / kubo / commits / b3e7cbb9a

refactor(commands) swap argument order to match Http(w, r) idiom

Brian Tiger Chow committed Oct 29, 2014 at 01:42 UTC b3e7cbb9a55845c87a432fe39141ab0761f4ad81
3 files changed +7 -7
cmd/ipfs2/daemon.go
+1 -1
@@ -20,7 +20,7 @@ var Daemon = &cmds.Command{
20 Run: daemonFunc,
21 }
22
23 -func daemonFunc(req cmds.Request, res cmds.Response) {
23 +func daemonFunc(res cmds.Response, req cmds.Request) {
24 ctx := req.Context()
25
26 node, err := core.NewIpfsNode(ctx.Config, true)
core/commands2/cat.go
+1 -1
@@ -9,7 +9,7 @@ import (
9
10 var cat = &cmds.Command{
11 Help: "TODO",
12 - Run: func(req cmds.Request, res cmds.Response) {
12 + Run: func(res cmds.Response, req cmds.Request) {
13 node := req.Context().Node
14 readers := make([]io.Reader, 0, len(req.Arguments()))
15
core/commands2/root.go
+5 -5
@@ -56,7 +56,7 @@ Use "ipfs help <command>" for more information about a command.
56 // test subcommands
57 // TODO: remove these when we don't need them anymore
58 "beep": &cmds.Command{
59 - Run: func(req cmds.Request, res cmds.Response) {
59 + Run: func(res cmds.Response, req cmds.Request) {
60 v := &TestOutput{"hello, world", 1337}
61 res.SetValue(v)
62 },
@@ -69,7 +69,7 @@ Use "ipfs help <command>" for more information about a command.
69 Type: &TestOutput{},
70 },
71 "boop": &cmds.Command{
72 - Run: func(req cmds.Request, res cmds.Response) {
72 + Run: func(res cmds.Response, req cmds.Request) {
73 v := strings.NewReader("hello, world")
74 res.SetValue(v)
75 },
@@ -78,7 +78,7 @@ Use "ipfs help <command>" for more information about a command.
78 Options: []cmds.Option{
79 cmds.Option{[]string{"power", "p"}, cmds.Float},
80 },
81 - Run: func(req cmds.Request, res cmds.Response) {
81 + Run: func(res cmds.Response, req cmds.Request) {
82 threshold := 1.21
83
84 if power, found := req.Option("power"); found && power.(float64) >= threshold {
@@ -94,12 +94,12 @@ Use "ipfs help <command>" for more information about a command.
94 },
95 },
96 "args": &cmds.Command{
97 - Run: func(req cmds.Request, res cmds.Response) {
97 + Run: func(res cmds.Response, req cmds.Request) {
98 res.SetValue(req.Arguments())
99 },
100 },
101 "echo": &cmds.Command{
102 - Run: func(req cmds.Request, res cmds.Response) {
102 + Run: func(res cmds.Response, req cmds.Request) {
103 res.SetValue(req.Stream())
104 },
105 },