Add version --all option
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
Jakub Sztandera committed
Jun 1, 2016 at 22:43 UTC
0bcfc493c6a235170016e2807791d96e043fe236
1 file changed
+17
core/commands/version.go
+17
@@ -3,6 +3,7 @@ package commands
3
import (
4
"fmt"
5
"io"
6
+ "runtime"
7
"strings"
8
9
cmds "github.com/ipfs/go-ipfs/commands"
@@ -14,6 +15,8 @@ type VersionOutput struct {
15
Version string
16
Commit string
17
Repo string
18
+ System string
19
+ Golang string
20
}
21
22
var VersionCmd = &cmds.Command{
@@ -26,12 +29,15 @@ var VersionCmd = &cmds.Command{
29
cmds.BoolOption("number", "n", "Only show the version number.").Default(false),
30
cmds.BoolOption("commit", "Show the commit hash.").Default(false),
31
cmds.BoolOption("repo", "Show repo version.").Default(false),
32
+ cmds.BoolOption("all", "Show all version information").Default(false),
33
},
34
Run: func(req cmds.Request, res cmds.Response) {
35
res.SetOutput(&VersionOutput{
36
Version: config.CurrentVersionNumber,
37
Commit: config.CurrentCommit,
38
Repo: fsrepo.RepoVersion,
39
+ System: runtime.GOARCH + "/" + runtime.GOOS, //TODO: Precise version here
40
+ Golang: runtime.Version(),
41
})
42
},
43
Marshalers: cmds.MarshalerMap{
@@ -64,6 +70,17 @@ var VersionCmd = &cmds.Command{
70
return strings.NewReader(fmt.Sprintln(v.Version + commitTxt)), nil
71
}
72
73
+ all, _, err := res.Request().Option("all").Bool()
74
+ if err != nil {
75
+ return nil, err
76
+ }
77
+ if all {
78
+ out := fmt.Sprintf("go-ipfs version: %s-%s\n"+
79
+ "Repo version: %s\nSystem version: %s\nGolang version: %s\n",
80
+ v.Version, v.Commit, v.Repo, v.System, v.Golang)
81
+ return strings.NewReader(out), nil
82
+ }
83
+
84
return strings.NewReader(fmt.Sprintf("ipfs version %s%s\n", v.Version, commitTxt)), nil
85
},
86
},