Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
f1c20b4e
提交
f1c20b4e
authored
11月 13, 2014
作者:
Brian Tiger Chow
提交者:
Juan Batiz-Benet
11月 14, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
don't use the marshaler
License: MIT Signed-off-by:
Brian Tiger Chow
<
brian@perfmode.com
>
上级
35da357d
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
10 行增加
和
48 行删除
+10
-48
tour.go
cmd/ipfs2/tour.go
+9
-47
tour_test.go
cmd/ipfs2/tour_test.go
+1
-1
没有找到文件。
cmd/ipfs2/tour.go
浏览文件 @
f1c20b4e
...
...
@@ -11,7 +11,6 @@ import (
config
"github.com/jbenet/go-ipfs/config"
internal
"github.com/jbenet/go-ipfs/core/commands2/internal"
tour
"github.com/jbenet/go-ipfs/tour"
"github.com/jbenet/go-ipfs/util"
)
// TODO the parent function now uses tourOutput. Migrate the children to also
...
...
@@ -38,46 +37,6 @@ IPFS very quickly. To start, run:
"restart"
:
cmdIpfsTourRestart
,
},
Run
:
tourRunFunc
,
Marshalers
:
cmds
.
MarshalerMap
{
cmds
.
Text
:
tourTextMarshaler
,
},
Type
:
&
tourOutput
{},
}
// tourOutput is a union type. It either contains a Topic or it contains the
// list of Topics and an Error.
type
tourOutput
struct
{
Last
tour
.
ID
Topic
*
tour
.
Topic
Topics
[]
tour
.
Topic
Error
error
}
func
tourTextMarshaler
(
r
cmds
.
Response
)
([]
byte
,
error
)
{
output
,
ok
:=
r
.
Output
()
.
(
*
tourOutput
)
if
!
ok
{
return
nil
,
util
.
ErrCast
()
}
// can be listing when error
var
buf
bytes
.
Buffer
err
:=
printTourOutput
(
&
buf
,
output
)
if
err
!=
nil
{
return
nil
,
err
}
return
buf
.
Bytes
(),
nil
}
func
printTourOutput
(
w
io
.
Writer
,
output
*
tourOutput
)
error
{
if
output
.
Error
!=
nil
{
fmt
.
Fprintln
(
w
,
"ERROR"
)
fmt
.
Fprintln
(
w
,
output
.
Error
.
Error
())
fmt
.
Fprintln
(
w
,
""
)
fprintTourList
(
w
,
output
.
Last
)
return
nil
// TODO err
}
return
fprintTourShow
(
w
,
output
.
Topic
)
}
func
tourRunFunc
(
req
cmds
.
Request
)
(
interface
{},
error
)
{
...
...
@@ -97,6 +56,8 @@ func tourRunFunc(req cmds.Request) (interface{}, error) {
id
=
tour
.
TopicID
(
strs
[
0
])
}
var
w
bytes
.
Buffer
defer
w
.
WriteTo
(
os
.
Stdout
)
t
,
err
:=
tourGet
(
id
)
if
err
!=
nil
{
...
...
@@ -106,15 +67,16 @@ func tourRunFunc(req cmds.Request) (interface{}, error) {
// 1) a simple error message
// 2) the full list of topics
output
:=
&
tourOutput
{
Error
:
err
,
Last
:
tour
.
TopicID
(
cfg
.
Tour
.
Last
),
}
fmt
.
Fprintln
(
&
w
,
"ERROR"
)
fmt
.
Fprintln
(
&
w
,
err
)
fmt
.
Fprintln
(
&
w
,
""
)
fprintTourList
(
&
w
,
tour
.
TopicID
(
cfg
.
Tour
.
Last
))
return
output
,
nil
return
nil
,
nil
}
return
&
tourOutput
{
Topic
:
t
},
nil
fprintTourShow
(
&
w
,
t
)
return
nil
,
nil
}
var
cmdIpfsTourNext
=
&
cmds
.
Command
{
...
...
cmd/ipfs2/tour_test.go
浏览文件 @
f1c20b4e
...
...
@@ -18,7 +18,7 @@ This is where we test our beautiful command line interfaces
`
,
}
var
buf
bytes
.
Buffer
err
:=
t
ourShow
(
&
buf
,
topic
)
err
:=
fprintT
ourShow
(
&
buf
,
topic
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论