Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 7b5c3d9

Browse files
committed
chore: add version command
Signed-off-by: Yves Brissaud <[email protected]>
1 parent 1977311 commit 7b5c3d9

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

commands/cmd.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import (
2424
"os"
2525
"strings"
2626

27+
"github.com/docker/index-cli-plugin/internal"
28+
2729
"github.com/moby/term"
2830
"github.com/pkg/errors"
2931
"github.com/sirupsen/logrus"
@@ -243,7 +245,18 @@ func NewRootCmd(name string, isPlugin bool, dockerCli command.Cli) *cobra.Comman
243245
},
244246
}
245247

246-
cmd.AddCommand(loginCommand, logoutCommand, sbomCommand, cveCommand, uploadCommand, diffCommand, watchCommand)
248+
versionCommand := &cobra.Command{
249+
Use: "version",
250+
Short: "Print version",
251+
Args: cobra.NoArgs,
252+
Run: func(_ *cobra.Command, _ []string) {
253+
v := internal.FromBuild()
254+
fmt.Printf("version: %s (%s - %s)\n", v.Version, v.GoVersion, v.Platform)
255+
fmt.Println("git commit:", v.Commit)
256+
},
257+
}
258+
259+
cmd.AddCommand(loginCommand, logoutCommand, sbomCommand, cveCommand, uploadCommand, diffCommand, watchCommand, versionCommand)
247260
return cmd
248261
}
249262

0 commit comments

Comments
 (0)