Commit 8cad2d2c authored by rht's avatar rht

Move 'tour' to core/commands

Side effect: this makes 'tour' accessible through the HTTP API
parent 4e71ce3c
...@@ -23,7 +23,6 @@ var commandsClientCmd = commands.CommandsCmd(Root) ...@@ -23,7 +23,6 @@ var commandsClientCmd = commands.CommandsCmd(Root)
var localCommands = map[string]*cmds.Command{ var localCommands = map[string]*cmds.Command{
"daemon": daemonCmd, "daemon": daemonCmd,
"init": initCmd, "init": initCmd,
"tour": tourCmd,
"commands": commandsClientCmd, "commands": commandsClientCmd,
} }
var localMap = make(map[*cmds.Command]bool) var localMap = make(map[*cmds.Command]bool)
......
...@@ -101,6 +101,7 @@ var rootSubcommands = map[string]*cmds.Command{ ...@@ -101,6 +101,7 @@ var rootSubcommands = map[string]*cmds.Command{
"resolve": ResolveCmd, "resolve": ResolveCmd,
"stats": StatsCmd, "stats": StatsCmd,
"swarm": SwarmCmd, "swarm": SwarmCmd,
"tour": tourCmd,
"update": UpdateCmd, "update": UpdateCmd,
"version": VersionCmd, "version": VersionCmd,
"bitswap": BitswapCmd, "bitswap": BitswapCmd,
......
package main package commands
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"html/template" "html/template"
"io" "io"
"os"
cmds "github.com/ipfs/go-ipfs/commands" cmds "github.com/ipfs/go-ipfs/commands"
config "github.com/ipfs/go-ipfs/repo/config" config "github.com/ipfs/go-ipfs/repo/config"
...@@ -50,7 +49,6 @@ func tourRunFunc(req cmds.Request, res cmds.Response) { ...@@ -50,7 +49,6 @@ func tourRunFunc(req cmds.Request, res cmds.Response) {
} }
var w bytes.Buffer var w bytes.Buffer
defer w.WriteTo(os.Stdout)
t, err := tourGet(id) t, err := tourGet(id)
if err != nil { if err != nil {
...@@ -64,11 +62,13 @@ func tourRunFunc(req cmds.Request, res cmds.Response) { ...@@ -64,11 +62,13 @@ func tourRunFunc(req cmds.Request, res cmds.Response) {
fmt.Fprintln(&w, err) fmt.Fprintln(&w, err)
fmt.Fprintln(&w, "") fmt.Fprintln(&w, "")
fprintTourList(&w, tour.TopicID(cfg.Tour.Last)) fprintTourList(&w, tour.TopicID(cfg.Tour.Last))
res.SetOutput(bytes.NewReader(w.Bytes()))
return return
} }
fprintTourShow(&w, t) fprintTourShow(&w, t)
res.SetOutput(bytes.NewReader(w.Bytes()))
} }
var cmdIpfsTourNext = &cmds.Command{ var cmdIpfsTourNext = &cmds.Command{
...@@ -106,7 +106,7 @@ var cmdIpfsTourNext = &cmds.Command{ ...@@ -106,7 +106,7 @@ var cmdIpfsTourNext = &cmds.Command{
} }
} }
w.WriteTo(os.Stdout) res.SetOutput(bytes.NewReader(w.Bytes()))
}, },
} }
...@@ -146,7 +146,7 @@ var cmdIpfsTourList = &cmds.Command{ ...@@ -146,7 +146,7 @@ var cmdIpfsTourList = &cmds.Command{
var w bytes.Buffer var w bytes.Buffer
fprintTourList(&w, tour.TopicID(cfg.Tour.Last)) fprintTourList(&w, tour.TopicID(cfg.Tour.Last))
w.WriteTo(os.Stdout) res.SetOutput(bytes.NewReader(w.Bytes()))
}, },
} }
......
package main package commands
import ( import (
"bytes" "bytes"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment