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

import (
4
	"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander"
5
	updates "github.com/jbenet/go-ipfs/updates"
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 9
)

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

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

func init() {
Juan Batiz-Benet's avatar
refmt  
Juan Batiz-Benet committed
20
	cmdIpfsVersion.Flag.Bool("number", false, "show only the number")
Juan Batiz-Benet's avatar
version  
Juan Batiz-Benet committed
21 22 23
}

func versionCmd(c *commander.Command, _ []string) error {
Juan Batiz-Benet's avatar
refmt  
Juan Batiz-Benet committed
24 25 26 27
	number := c.Flag.Lookup("number").Value.Get().(bool)
	if !number {
		u.POut("ipfs version ")
	}
28
	u.POut("%s\n", updates.Version)
29 30
	return nil
}