version.go 836 Bytes
Newer Older
Juan Batiz-Benet's avatar
version  
Juan Batiz-Benet committed
1 2 3
package main

import (
4
	semver "github.com/coreos/go-semver/semver"
5
	"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander"
Juan Batiz-Benet's avatar
refmt  
Juan Batiz-Benet committed
6
	u "github.com/jbenet/go-ipfs/util"
Juan Batiz-Benet's avatar
version  
Juan Batiz-Benet committed
7 8
)

Juan Batiz-Benet's avatar
go lint  
Juan Batiz-Benet committed
9
// The IPFS version.
Juan Batiz-Benet's avatar
version  
Juan Batiz-Benet committed
10 11 12
const Version = "0.1.0"

var cmdIpfsVersion = &commander.Command{
Juan Batiz-Benet's avatar
refmt  
Juan Batiz-Benet committed
13 14 15
	UsageLine: "version",
	Short:     "Show ipfs version information.",
	Long: `ipfs version - Show ipfs version information.
Juan Batiz-Benet's avatar
version  
Juan Batiz-Benet committed
16 17 18

    Returns the current version of ipfs and exits.
  `,
Juan Batiz-Benet's avatar
refmt  
Juan Batiz-Benet committed
19
	Run: versionCmd,
Juan Batiz-Benet's avatar
version  
Juan Batiz-Benet committed
20 21
}

22 23
var currentVersion *semver.Version

Juan Batiz-Benet's avatar
version  
Juan Batiz-Benet committed
24
func init() {
25
	currentVersion, _ = semver.NewVersion(Version)
Juan Batiz-Benet's avatar
refmt  
Juan Batiz-Benet committed
26
	cmdIpfsVersion.Flag.Bool("number", false, "show only the number")
Juan Batiz-Benet's avatar
version  
Juan Batiz-Benet committed
27 28 29
}

func versionCmd(c *commander.Command, _ []string) error {
Juan Batiz-Benet's avatar
refmt  
Juan Batiz-Benet committed
30 31 32 33 34 35
	number := c.Flag.Lookup("number").Value.Get().(bool)
	if !number {
		u.POut("ipfs version ")
	}
	u.POut("%s\n", Version)
	return nil
Juan Batiz-Benet's avatar
version  
Juan Batiz-Benet committed
36
}