forked from metalsoft-io/metalcloud-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmd_version.go
34 lines (29 loc) · 886 Bytes
/
cmd_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
package main
import (
"flag"
"fmt"
metalcloud "github.com/metalsoft-io/metal-cloud-sdk-go/v2"
)
var versionCmds = []Command{
{
Description: "Show version.",
Subject: "version",
AltSubject: "version",
Predicate: "show",
AltPredicate: "show",
FlagSet: flag.NewFlagSet("list variables", flag.ExitOnError),
InitFunc: func(c *Command) {
c.Arguments = map[string]interface{}{
"format": c.FlagSet.String("format", _nilDefaultStr, "The output format. Supported values are 'json','csv','yaml'. The default format is human readable."),
}
},
ExecuteFunc: versionShowCmd,
Endpoint: UserEndpoint,
},
}
func versionShowCmd(c *Command, client metalcloud.MetalCloudClient) (string, error) {
if version == "" {
return fmt.Sprintf("manual build\n"), nil
}
return fmt.Sprintf("Version %s, build %s, date %s\n", version, commit, date), nil
}