Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
40a1c757
提交
40a1c757
authored
10月 26, 2018
作者:
Overbool
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(cmds): use new cmds lib in version
License: MIT Signed-off-by:
Overbool
<
overbool.xu@gmail.com
>
上级
2235472d
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
20 行增加
和
41 行删除
+20
-41
root.go
core/commands/root.go
+2
-2
version.go
core/commands/version.go
+18
-39
没有找到文件。
core/commands/root.go
浏览文件 @
40a1c757
...
...
@@ -145,7 +145,7 @@ var rootSubcommands = map[string]*cmds.Command{
"file"
:
lgc
.
NewCommand
(
unixfs
.
UnixFSCmd
),
"update"
:
lgc
.
NewCommand
(
ExternalBinary
()),
"urlstore"
:
urlStoreCmd
,
"version"
:
lgc
.
NewCommand
(
VersionCmd
)
,
"version"
:
VersionCmd
,
"shutdown"
:
daemonShutdownCmd
,
"cid"
:
CidCmd
,
}
...
...
@@ -189,7 +189,7 @@ var rootROSubcommands = map[string]*cmds.Command{
},
}),
"resolve"
:
ResolveCmd
,
"version"
:
lgc
.
NewCommand
(
VersionCmd
)
,
"version"
:
VersionCmd
,
}
func
init
()
{
...
...
core/commands/version.go
浏览文件 @
40a1c757
...
...
@@ -4,13 +4,11 @@ import (
"fmt"
"io"
"runtime"
"strings"
version
"github.com/ipfs/go-ipfs"
cmds
"github.com/ipfs/go-ipfs/commands"
e
"github.com/ipfs/go-ipfs/core/commands/e"
fsrepo
"github.com/ipfs/go-ipfs/repo/fsrepo"
cmds
"gx/ipfs/QmRRovo1DE6i5cMjCbf19mQCSuszF6SKwdZNUMS7MtBnH1/go-ipfs-cmds"
"gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit"
)
...
...
@@ -41,8 +39,8 @@ var VersionCmd = &cmds.Command{
cmdkit
.
BoolOption
(
versionRepoOptionName
,
"Show repo version."
),
cmdkit
.
BoolOption
(
versionAllOptionName
,
"Show all version information"
),
},
Run
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
re
s
.
SetOutpu
t
(
&
VersionOutput
{
Run
:
func
(
req
*
cmds
.
Request
,
res
cmds
.
ResponseEmitter
,
env
cmds
.
Environment
)
error
{
re
turn
res
.
Emi
t
(
&
VersionOutput
{
Version
:
version
.
CurrentVersionNumber
,
Commit
:
version
.
CurrentCommit
,
Repo
:
fmt
.
Sprint
(
fsrepo
.
RepoVersion
),
...
...
@@ -50,57 +48,38 @@ var VersionCmd = &cmds.Command{
Golang
:
runtime
.
Version
(),
})
},
Marshalers
:
cmds
.
MarshalerMap
{
cmds
.
Text
:
func
(
res
cmds
.
Response
)
(
io
.
Reader
,
error
)
{
v
,
err
:=
unwrapOutput
(
res
.
Output
())
if
err
!=
nil
{
return
nil
,
err
}
version
,
ok
:=
v
.
(
*
VersionOutput
)
if
!
ok
{
return
nil
,
e
.
TypeErr
(
version
,
v
)
}
repo
,
_
,
err
:=
res
.
Request
()
.
Option
(
versionRepoOptionName
)
.
Bool
()
if
err
!=
nil
{
return
nil
,
err
}
Encoders
:
cmds
.
EncoderMap
{
cmds
.
Text
:
cmds
.
MakeTypedEncoder
(
func
(
req
*
cmds
.
Request
,
w
io
.
Writer
,
version
*
VersionOutput
)
error
{
repo
,
_
:=
req
.
Options
[
versionRepoOptionName
]
.
(
bool
)
if
repo
{
return
strings
.
NewReader
(
version
.
Repo
+
"
\n
"
),
nil
fmt
.
Fprintln
(
w
,
version
.
Repo
)
return
nil
}
commit
,
_
,
err
:=
res
.
Request
()
.
Option
(
versionCommitOptionName
)
.
Bool
(
)
commit
,
_
:=
req
.
Options
[
versionCommitOptionName
]
.
(
bool
)
commitTxt
:=
""
if
err
!=
nil
{
return
nil
,
err
}
if
commit
{
commitTxt
=
"-"
+
version
.
Commit
}
number
,
_
,
err
:=
res
.
Request
()
.
Option
(
versionNumberOptionName
)
.
Bool
()
if
err
!=
nil
{
return
nil
,
err
}
number
,
_
:=
req
.
Options
[
versionNumberOptionName
]
.
(
bool
)
if
number
{
return
strings
.
NewReader
(
fmt
.
Sprintln
(
version
.
Version
+
commitTxt
)),
nil
fmt
.
Fprintln
(
w
,
version
.
Version
+
commitTxt
)
return
nil
}
all
,
_
,
err
:=
res
.
Request
()
.
Option
(
versionAllOptionName
)
.
Bool
()
if
err
!=
nil
{
return
nil
,
err
}
all
,
_
:=
req
.
Options
[
versionAllOptionName
]
.
(
bool
)
if
all
{
out
:=
fmt
.
Sprintf
(
"go-ipfs version: %s-%s
\n
"
+
"Repo version: %s
\n
System version: %s
\n
Golang version: %s
\n
"
,
version
.
Version
,
version
.
Commit
,
version
.
Repo
,
version
.
System
,
version
.
Golang
)
return
strings
.
NewReader
(
out
),
nil
fmt
.
Fprint
(
w
,
out
)
return
nil
}
return
strings
.
NewReader
(
fmt
.
Sprintf
(
"ipfs version %s%s
\n
"
,
version
.
Version
,
commitTxt
)),
nil
},
fmt
.
Fprint
(
w
,
fmt
.
Sprintf
(
"ipfs version %s%s
\n
"
,
version
.
Version
,
commitTxt
))
return
nil
}),
},
Type
:
VersionOutput
{},
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论