Skip to content

Commit 009795f

Browse files
author
rht
committed
Move 'tour' to core/commands
Side effect: this makes 'tour' accessible through the HTTP API
1 parent 7f38eaa commit 009795f

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

cmd/ipfs/ipfs.go

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ var commandsClientCmd = commands.CommandsCmd(Root)
2323
var localCommands = map[string]*cmds.Command{
2424
"daemon": daemonCmd,
2525
"init": initCmd,
26-
"tour": tourCmd,
2726
"commands": commandsClientCmd,
2827
}
2928
var localMap = make(map[*cmds.Command]bool)

core/commands/root.go

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ var rootSubcommands = map[string]*cmds.Command{
101101
"resolve": ResolveCmd,
102102
"stats": StatsCmd,
103103
"swarm": SwarmCmd,
104+
"tour": tourCmd,
104105
"update": UpdateCmd,
105106
"version": VersionCmd,
106107
"bitswap": BitswapCmd,

cmd/ipfs/tour.go renamed to core/commands/tour.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
package main
1+
package commands
22

33
import (
44
"bytes"
55
"fmt"
66
"html/template"
77
"io"
8-
"os"
98

109
cmds "github.com/ipfs/go-ipfs/commands"
1110
config "github.com/ipfs/go-ipfs/repo/config"
@@ -50,7 +49,6 @@ func tourRunFunc(req cmds.Request, res cmds.Response) {
5049
}
5150

5251
var w bytes.Buffer
53-
defer w.WriteTo(os.Stdout)
5452
t, err := tourGet(id)
5553
if err != nil {
5654

@@ -64,11 +62,13 @@ func tourRunFunc(req cmds.Request, res cmds.Response) {
6462
fmt.Fprintln(&w, err)
6563
fmt.Fprintln(&w, "")
6664
fprintTourList(&w, tour.TopicID(cfg.Tour.Last))
65+
res.SetOutput(bytes.NewReader(w.Bytes()))
6766

6867
return
6968
}
7069

7170
fprintTourShow(&w, t)
71+
res.SetOutput(bytes.NewReader(w.Bytes()))
7272
}
7373

7474
var cmdIpfsTourNext = &cmds.Command{
@@ -106,7 +106,7 @@ var cmdIpfsTourNext = &cmds.Command{
106106
}
107107
}
108108

109-
w.WriteTo(os.Stdout)
109+
res.SetOutput(bytes.NewReader(w.Bytes()))
110110
},
111111
}
112112

@@ -146,7 +146,7 @@ var cmdIpfsTourList = &cmds.Command{
146146

147147
var w bytes.Buffer
148148
fprintTourList(&w, tour.TopicID(cfg.Tour.Last))
149-
w.WriteTo(os.Stdout)
149+
res.SetOutput(bytes.NewReader(w.Bytes()))
150150
},
151151
}
152152

cmd/ipfs/tour_test.go renamed to core/commands/tour_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package commands
22

33
import (
44
"bytes"

0 commit comments

Comments
 (0)