github.com/devcamcar/cli@v0.0.0-20181107134215-706a05759d18/commands/version.go (about) 1 package commands 2 3 import ( 4 "fmt" 5 6 "github.com/fnproject/cli/client" 7 "github.com/fnproject/cli/config" 8 "github.com/urfave/cli" 9 ) 10 11 // VersionCommand 12 func VersionCommand() cli.Command { 13 return cli.Command{ 14 Name: "version", 15 Usage: "Display Fn CLI and Fn Server versions", 16 Description: "This command shows the version of the Fn CLI being used and the version of the Fn Server referenced by the current context, if available.", 17 Action: versionCMD, 18 } 19 } 20 21 func versionCMD(c *cli.Context) error { 22 provider, err := client.CurrentProvider() 23 if err != nil { 24 return err 25 } 26 27 ver := config.GetVersion("latest") 28 if ver == "" { 29 ver = "Client version: " + config.Version 30 } 31 fmt.Println(ver) 32 33 versionClient := provider.VersionClient() 34 v, err := versionClient.GetVersion(nil) 35 if err != nil { 36 fmt.Println("Server version: ", "?") 37 return nil 38 } 39 fmt.Println("Server version: ", v.Payload.Version) 40 return nil 41 }