diff --git a/cli/Makefile b/cli/Makefile new file mode 100644 index 000000000..fcc01c36a --- /dev/null +++ b/cli/Makefile @@ -0,0 +1,5 @@ +all: build + +build: + go build + mv cli ipfs diff --git a/cli/commands.go b/cli/commands.go index b605fcf11..47d52a38b 100644 --- a/cli/commands.go +++ b/cli/commands.go @@ -34,7 +34,7 @@ Use "ipfs help " for more information about a command. `, Run: ipfsCmd, Subcommands: []*commander.Command{ - // cmdIpfsVersion, + cmdIpfsVersion, // cmdIpfsConfig, cmdIpfsCommands, }, diff --git a/cli/version.go b/cli/version.go new file mode 100644 index 000000000..dd301a18d --- /dev/null +++ b/cli/version.go @@ -0,0 +1,31 @@ +package main + +import ( + "github.com/jbenet/commander" + u "github.com/jbenet/go-ipfs/util" +) + +const Version = "0.1.0" + +var cmdIpfsVersion = &commander.Command{ + UsageLine: "version", + Short: "Show ipfs version information.", + Long: `ipfs version - Show ipfs version information. + + Returns the current version of ipfs and exits. + `, + Run: versionCmd, +} + +func init() { + cmdIpfsVersion.Flag.Bool("number", false, "show only the number") +} + +func versionCmd(c *commander.Command, _ []string) error { + number := c.Flag.Lookup("number").Value.Get().(bool) + if !number { + u.POut("ipfs version ") + } + u.POut("%s\n", Version) + return nil +}