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

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

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

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

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

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

func versionCmd(c *commander.Command, _ []string) error {
Juan Batiz-Benet's avatar
refmt  
Juan Batiz-Benet committed
26 27 28 29 30 31
	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
32
}