fix(2/version)
License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
Brian Tiger Chow committed
Nov 13, 2014 at 21:30 UTC
80dcc5d237e6b3aa13b11c381e90ca1f966168d3
1 file changed
+12
-12
core/commands2/version.go
+12
-12
@@ -1,6 +1,8 @@
1
package commands
2
3
import (
4
+ "fmt"
5
+
6
cmds "github.com/jbenet/go-ipfs/commands"
7
config "github.com/jbenet/go-ipfs/config"
8
)
@@ -11,12 +13,16 @@ type VersionOutput struct {
13
14
var VersionCmd = &cmds.Command{
15
Helptext: cmds.HelpText{
14
- Tagline: "Outputs the current version of IPFS",
15
- ShortDescription: "Returns the version number of IPFS and exits.",
16
+ Tagline: "Shows ipfs version information",
17
+ ShortDescription: "Shows ipfs version information",
18
+ LongDescription: `ipfs version - Show ipfs version information.
19
+
20
+ Returns the current version of ipfs and exits.
21
+ `,
22
},
23
24
Options: []cmds.Option{
19
- cmds.BoolOption("number", "n", "Only output the version number"),
25
+ cmds.BoolOption("number", "n", "Only show the version number"),
26
},
27
Run: func(req cmds.Request) (interface{}, error) {
28
return &VersionOutput{
@@ -26,21 +32,15 @@ var VersionCmd = &cmds.Command{
32
Marshalers: cmds.MarshalerMap{
33
cmds.Text: func(res cmds.Response) ([]byte, error) {
34
v := res.Output().(*VersionOutput)
29
- s := ""
35
36
number, found, err := res.Request().Option("number").Bool()
37
if err != nil {
38
return nil, err
39
}
35
- if !found {
36
- number = false
37
- }
38
-
39
- if !number {
40
- s += "ipfs version "
40
+ if found && number {
41
+ return []byte(fmt.Sprintln(v.Version)), nil
42
}
42
- s += v.Version
43
- return []byte(s), nil
43
+ return []byte(fmt.Sprintf("ipfs version %s\n", v.Version)), nil
44
},
45
},
46
Type: &VersionOutput{},