提交 0bcfc493 作者: Jakub Sztandera

Add version --all option

License: MIT
Signed-off-by: 's avatarJakub Sztandera <kubuxu@protonmail.ch>
上级 fd1eae87
......@@ -3,6 +3,7 @@ package commands
import (
"fmt"
"io"
"runtime"
"strings"
cmds "github.com/ipfs/go-ipfs/commands"
......@@ -14,6 +15,8 @@ type VersionOutput struct {
Version string
Commit string
Repo string
System string
Golang string
}
var VersionCmd = &cmds.Command{
......@@ -26,12 +29,15 @@ var VersionCmd = &cmds.Command{
cmds.BoolOption("number", "n", "Only show the version number.").Default(false),
cmds.BoolOption("commit", "Show the commit hash.").Default(false),
cmds.BoolOption("repo", "Show repo version.").Default(false),
cmds.BoolOption("all", "Show all version information").Default(false),
},
Run: func(req cmds.Request, res cmds.Response) {
res.SetOutput(&VersionOutput{
Version: config.CurrentVersionNumber,
Commit: config.CurrentCommit,
Repo: fsrepo.RepoVersion,
System: runtime.GOARCH + "/" + runtime.GOOS, //TODO: Precise version here
Golang: runtime.Version(),
})
},
Marshalers: cmds.MarshalerMap{
......@@ -64,6 +70,17 @@ var VersionCmd = &cmds.Command{
return strings.NewReader(fmt.Sprintln(v.Version + commitTxt)), nil
}
all, _, err := res.Request().Option("all").Bool()
if err != nil {
return nil, err
}
if all {
out := fmt.Sprintf("go-ipfs version: %s-%s\n"+
"Repo version: %s\nSystem version: %s\nGolang version: %s\n",
v.Version, v.Commit, v.Repo, v.System, v.Golang)
return strings.NewReader(out), nil
}
return strings.NewReader(fmt.Sprintf("ipfs version %s%s\n", v.Version, commitTxt)), nil
},
},
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论