Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
0afd3391
提交
0afd3391
authored
11月 03, 2014
作者:
Matt Bell
提交者:
Juan Batiz-Benet
11月 14, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
commands: Replaced 'Formatter' with 'Marshaller'
上级
3dd7a9a5
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
17 行增加
和
14 行删除
+17
-14
add.go
core/commands2/add.go
+4
-3
commands.go
core/commands2/commands.go
+3
-2
log.go
core/commands2/log.go
+1
-1
ls.go
core/commands2/ls.go
+2
-2
publish.go
core/commands2/publish.go
+3
-2
root.go
core/commands2/root.go
+4
-4
没有找到文件。
core/commands2/add.go
浏览文件 @
0afd3391
...
...
@@ -55,17 +55,18 @@ var addCmd = &cmds.Command{
res
.
SetOutput
(
&
AddOutput
{
added
})
},
Format
:
func
(
res
cmds
.
Response
)
(
string
,
error
)
{
Format
:
func
(
res
cmds
.
Response
)
(
[]
byte
,
error
)
{
v
:=
res
.
Output
()
.
(
*
AddOutput
)
.
Added
if
len
(
v
)
==
1
{
return
fmt
.
Sprintf
(
"Added object: %s
\n
"
,
v
[
0
]
.
Hash
),
nil
s
:=
fmt
.
Sprintf
(
"Added object: %s
\n
"
,
v
[
0
]
.
Hash
)
return
[]
byte
(
s
),
nil
}
s
:=
fmt
.
Sprintf
(
"Added %v objects:
\n
"
,
len
(
v
))
for
_
,
obj
:=
range
v
{
s
+=
fmt
.
Sprintf
(
"- %s
\n
"
,
obj
.
Hash
)
}
return
s
,
nil
return
[]
byte
(
s
)
,
nil
},
Type
:
&
AddOutput
{},
}
...
...
core/commands2/commands.go
浏览文件 @
0afd3391
...
...
@@ -18,9 +18,10 @@ var commandsCmd = &cmds.Command{
root
:=
outputCommand
(
"ipfs"
,
Root
)
res
.
SetOutput
(
&
root
)
},
Format
:
func
(
res
cmds
.
Response
)
(
string
,
error
)
{
Format
:
func
(
res
cmds
.
Response
)
(
[]
byte
,
error
)
{
v
:=
res
.
Output
()
.
(
*
Command
)
return
formatCommand
(
v
,
0
),
nil
s
:=
formatCommand
(
v
,
0
)
return
[]
byte
(
s
),
nil
},
Type
:
&
Command
{},
}
...
...
core/commands2/log.go
浏览文件 @
0afd3391
...
...
@@ -23,6 +23,6 @@ var logCmd = &cmds.Command{
s
:=
fmt
.
Sprintf
(
"Changed log level of '%s' to '%s'"
,
args
[
0
],
args
[
1
])
res
.
SetOutput
(
&
MessageOutput
{
s
})
},
Format
:
Message
Formatt
er
,
Format
:
Message
Marshall
er
,
Type
:
&
MessageOutput
{},
}
core/commands2/ls.go
浏览文件 @
0afd3391
...
...
@@ -52,7 +52,7 @@ var lsCmd = &cmds.Command{
res
.
SetOutput
(
&
LsOutput
{
output
})
},
Format
:
func
(
res
cmds
.
Response
)
(
string
,
error
)
{
Format
:
func
(
res
cmds
.
Response
)
(
[]
byte
,
error
)
{
s
:=
""
output
:=
res
.
Output
()
.
(
*
LsOutput
)
.
Objects
...
...
@@ -70,7 +70,7 @@ var lsCmd = &cmds.Command{
}
}
return
s
,
nil
return
[]
byte
(
s
)
,
nil
},
Type
:
&
LsOutput
{},
}
core/commands2/publish.go
浏览文件 @
0afd3391
...
...
@@ -61,9 +61,10 @@ var publishCmd = &cmds.Command{
Value
:
ref
,
})
},
Format
:
func
(
res
cmds
.
Response
)
(
string
,
error
)
{
Format
:
func
(
res
cmds
.
Response
)
(
[]
byte
,
error
)
{
v
:=
res
.
Output
()
.
(
*
PublishOutput
)
return
fmt
.
Sprintf
(
"Published name %s to %s
\n
"
,
v
.
Name
,
v
.
Value
),
nil
s
:=
fmt
.
Sprintf
(
"Published name %s to %s
\n
"
,
v
.
Name
,
v
.
Value
)
return
[]
byte
(
s
),
nil
},
Type
:
&
PublishOutput
{},
}
core/commands2/root.go
浏览文件 @
0afd3391
...
...
@@ -71,11 +71,11 @@ var rootSubcommands = map[string]*cmds.Command{
log
.
Info
(
"beep"
)
res
.
SetOutput
(
v
)
},
Format
:
func
(
res
cmds
.
Response
)
(
string
,
error
)
{
Format
:
func
(
res
cmds
.
Response
)
(
[]
byte
,
error
)
{
v
:=
res
.
Output
()
.
(
*
TestOutput
)
s
:=
fmt
.
Sprintf
(
"Foo: %s
\n
"
,
v
.
Foo
)
s
+=
fmt
.
Sprintf
(
"Bar: %v
\n
"
,
v
.
Bar
)
return
s
,
nil
return
[]
byte
(
s
)
,
nil
},
Type
:
&
TestOutput
{},
},
...
...
@@ -120,6 +120,6 @@ type MessageOutput struct {
Message
string
}
func
Message
Formatter
(
res
cmds
.
Response
)
(
string
,
error
)
{
return
res
.
Output
()
.
(
*
MessageOutput
)
.
Message
,
nil
func
Message
Marshaller
(
res
cmds
.
Response
)
([]
byte
,
error
)
{
return
[]
byte
(
res
.
Output
()
.
(
*
MessageOutput
)
.
Message
)
,
nil
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论