Commit 80dcc5d2 authored by Brian Tiger Chow's avatar Brian Tiger Chow Committed by Juan Batiz-Benet

fix(2/version)

License: MIT
Signed-off-by: default avatarBrian Tiger Chow <brian@perfmode.com>
parent 65eb1d86
package commands package commands
import ( import (
"fmt"
cmds "github.com/jbenet/go-ipfs/commands" cmds "github.com/jbenet/go-ipfs/commands"
config "github.com/jbenet/go-ipfs/config" config "github.com/jbenet/go-ipfs/config"
) )
...@@ -11,12 +13,16 @@ type VersionOutput struct { ...@@ -11,12 +13,16 @@ type VersionOutput struct {
var VersionCmd = &cmds.Command{ var VersionCmd = &cmds.Command{
Helptext: cmds.HelpText{ Helptext: cmds.HelpText{
Tagline: "Outputs the current version of IPFS", Tagline: "Shows ipfs version information",
ShortDescription: "Returns the version number of IPFS and exits.", ShortDescription: "Shows ipfs version information",
LongDescription: `ipfs version - Show ipfs version information.
Returns the current version of ipfs and exits.
`,
}, },
Options: []cmds.Option{ Options: []cmds.Option{
cmds.BoolOption("number", "n", "Only output the version number"), cmds.BoolOption("number", "n", "Only show the version number"),
}, },
Run: func(req cmds.Request) (interface{}, error) { Run: func(req cmds.Request) (interface{}, error) {
return &VersionOutput{ return &VersionOutput{
...@@ -26,21 +32,15 @@ var VersionCmd = &cmds.Command{ ...@@ -26,21 +32,15 @@ var VersionCmd = &cmds.Command{
Marshalers: cmds.MarshalerMap{ Marshalers: cmds.MarshalerMap{
cmds.Text: func(res cmds.Response) ([]byte, error) { cmds.Text: func(res cmds.Response) ([]byte, error) {
v := res.Output().(*VersionOutput) v := res.Output().(*VersionOutput)
s := ""
number, found, err := res.Request().Option("number").Bool() number, found, err := res.Request().Option("number").Bool()
if err != nil { if err != nil {
return nil, err return nil, err
} }
if !found { if found && number {
number = false return []byte(fmt.Sprintln(v.Version)), nil
}
if !number {
s += "ipfs version "
} }
s += v.Version return []byte(fmt.Sprintf("ipfs version %s\n", v.Version)), nil
return []byte(s), nil
}, },
}, },
Type: &VersionOutput{}, Type: &VersionOutput{},
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment