Skip to content

Commit

Permalink
Show extension information in k6 version output
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Mirić authored and imiric committed Dec 20, 2022
1 parent 8e543c0 commit cbbb19d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestVersion(t *testing.T) {
assert.Contains(t, stdOut, runtime.Version())
assert.Contains(t, stdOut, runtime.GOOS)
assert.Contains(t, stdOut, runtime.GOARCH)
assert.NotContains(t, stdOut[:len(stdOut)-1], "\n")
assert.Contains(t, stdOut, "k6/x/alarmist")

assert.Empty(t, ts.stdErr.Bytes())
assert.Empty(t, ts.loggerHook.Drain())
Expand Down
11 changes: 11 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package cmd

import (
"fmt"
"strings"

"github.com/spf13/cobra"

"go.k6.io/k6/ext"
"go.k6.io/k6/lib/consts"
)

Expand All @@ -16,6 +18,15 @@ func getCmdVersion(globalState *globalState) *cobra.Command {
Long: `Show the application version and exit.`,
Run: func(_ *cobra.Command, _ []string) {
printToStdout(globalState, fmt.Sprintf("k6 v%s\n", 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()))
}
printToStdout(globalState, fmt.Sprintf("Extensions:\n%s\n",
strings.Join(extsDesc, "\n")))
}
},
}
}

0 comments on commit cbbb19d

Please sign in to comment.