Move 'tour' to core/commands
Side effect: this makes 'tour' accessible through the HTTP API
rht committed
May 26, 2015 at 20:23 UTC
8cad2d2c891b745527e37ca0f7c14357363fdc44
4 files changed
+7
-7
cmd/ipfs/ipfs.go
-1
@@ -23,7 +23,6 @@ var commandsClientCmd = commands.CommandsCmd(Root)
23
var localCommands = map[string]*cmds.Command{
24
"daemon": daemonCmd,
25
"init": initCmd,
26
- "tour": tourCmd,
26
"commands": commandsClientCmd,
27
}
28
var localMap = make(map[*cmds.Command]bool)
core/commands/root.go
+1
@@ -101,6 +101,7 @@ var rootSubcommands = map[string]*cmds.Command{
101
"resolve": ResolveCmd,
102
"stats": StatsCmd,
103
"swarm": SwarmCmd,
104
+ "tour": tourCmd,
105
"update": UpdateCmd,
106
"version": VersionCmd,
107
"bitswap": BitswapCmd,
core/commands/tour.go
renamed
+5
-5
@@ -1,11 +1,10 @@
1
-package main
1
+package commands
2
3
import (
4
"bytes"
5
"fmt"
6
"html/template"
7
"io"
8
- "os"
8
9
cmds "github.com/ipfs/go-ipfs/commands"
10
config "github.com/ipfs/go-ipfs/repo/config"
@@ -50,7 +49,6 @@ func tourRunFunc(req cmds.Request, res cmds.Response) {
49
}
50
51
var w bytes.Buffer
53
- defer w.WriteTo(os.Stdout)
52
t, err := tourGet(id)
53
if err != nil {
54
@@ -64,11 +62,13 @@ func tourRunFunc(req cmds.Request, res cmds.Response) {
62
fmt.Fprintln(&w, err)
63
fmt.Fprintln(&w, "")
64
fprintTourList(&w, tour.TopicID(cfg.Tour.Last))
65
+ res.SetOutput(bytes.NewReader(w.Bytes()))
66
67
return
68
}
69
70
fprintTourShow(&w, t)
71
+ res.SetOutput(bytes.NewReader(w.Bytes()))
72
}
73
74
var cmdIpfsTourNext = &cmds.Command{
@@ -106,7 +106,7 @@ var cmdIpfsTourNext = &cmds.Command{
106
}
107
}
108
109
- w.WriteTo(os.Stdout)
109
+ res.SetOutput(bytes.NewReader(w.Bytes()))
110
},
111
}
112
@@ -146,7 +146,7 @@ var cmdIpfsTourList = &cmds.Command{
146
147
var w bytes.Buffer
148
fprintTourList(&w, tour.TopicID(cfg.Tour.Last))
149
- w.WriteTo(os.Stdout)
149
+ res.SetOutput(bytes.NewReader(w.Bytes()))
150
},
151
}
152
core/commands/tour_test.go
renamed
+1
-1
@@ -1,4 +1,4 @@
1
-package main
1
+package commands
2
3
import (
4
"bytes"