forked from carimura/cli
-
Notifications
You must be signed in to change notification settings - Fork 1
/
version.go
47 lines (39 loc) · 835 Bytes
/
version.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"fmt"
"net/url"
"os"
functions "github.com/funcy/functions_go"
"github.com/urfave/cli"
)
// Version of Functions CLI
var Version = "0.3.66"
func version() cli.Command {
r := versionCmd{VersionApi: functions.NewVersionApi()}
return cli.Command{
Name: "version",
Usage: "displays fn and functions daemon versions",
Action: r.version,
}
}
type versionCmd struct {
*functions.VersionApi
}
func (r *versionCmd) version(c *cli.Context) error {
apiURL := os.Getenv("API_URL")
if apiURL == "" {
apiURL = "http://localhost:8080"
}
u, err := url.Parse(apiURL)
if err != nil {
return err
}
r.Configuration.BasePath = u.String()
fmt.Println("Client version:", Version)
v, _, err := r.VersionGet()
if err != nil {
return err
}
fmt.Println("Server version", v.Version)
return nil
}