forked from grafana/k6
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathversion.go
39 lines (34 loc) · 845 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
package cmd
import (
"fmt"
"strings"
"github.com/spf13/cobra"
"go.k6.io/k6/cmd/state"
"go.k6.io/k6/ext"
"go.k6.io/k6/lib/consts"
)
func versionString() string {
v := consts.FullVersion()
if exts := ext.GetAll(); len(exts) > 0 {
extsDesc := make([]string, 0, len(exts))
for _, e := range exts {
extsDesc = append(extsDesc, fmt.Sprintf(" %s", e.String()))
}
v += fmt.Sprintf("\nExtensions:\n%s\n",
strings.Join(extsDesc, "\n"))
}
return v
}
func getCmdVersion(_ *state.GlobalState) *cobra.Command {
// versionCmd represents the version command.
return &cobra.Command{
Use: "version",
Short: "Show application version",
Long: `Show the application version and exit.`,
Run: func(cmd *cobra.Command, _ []string) {
root := cmd.Root()
root.SetArgs([]string{"--version"})
_ = root.Execute()
},
}
}