github.com/zignig/go-ipfs@v0.0.0-20141111235910-c9e5fdf55a52/core/commands2/version.go (about) 1 package commands 2 3 import ( 4 cmds "github.com/jbenet/go-ipfs/commands" 5 config "github.com/jbenet/go-ipfs/config" 6 ) 7 8 type VersionOutput struct { 9 Version string 10 } 11 12 var versionCmd = &cmds.Command{ 13 Description: "Outputs the current version of IPFS", 14 Help: `Returns the version number of IPFS and exits. 15 `, 16 17 Options: []cmds.Option{ 18 cmds.BoolOption("number", "n", "Only output the version number"), 19 }, 20 Run: func(req cmds.Request) (interface{}, error) { 21 return &VersionOutput{ 22 Version: config.CurrentVersionNumber, 23 }, nil 24 }, 25 Marshallers: map[cmds.EncodingType]cmds.Marshaller{ 26 cmds.Text: func(res cmds.Response) ([]byte, error) { 27 v := res.Output().(*VersionOutput) 28 s := "" 29 30 number, _ := res.Request().Option("number").Bool() 31 32 if !number { 33 s += "ipfs version " 34 } 35 s += v.Version 36 return []byte(s), nil 37 }, 38 }, 39 Type: &VersionOutput{}, 40 }