mirror of
https://github.com/containerd/containerd.git
synced 2026-08-09 17:39:22 +00:00
cmd/containerd-stress: enable '--version' flag
All other binaries have a `-v` and/or `--version` flag, which can be
useful to perform a quick check if the binary is "functional".
Before this:
containerd-stress --version | tail -n1
flag provided but not defined: -version
--help, -h Show help
After this:
containerd-stress --version | tail -n1
containerd-stress github.com/containerd/containerd/v2 v2.2.0-306-g2e46d7659.m
containerd-stress --help | tail -n1
--version, -v Print the version
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -33,6 +33,7 @@ import (
|
||||
"github.com/containerd/containerd/v2/integration/remote"
|
||||
"github.com/containerd/containerd/v2/pkg/namespaces"
|
||||
"github.com/containerd/containerd/v2/plugins"
|
||||
"github.com/containerd/containerd/v2/version"
|
||||
"github.com/containerd/log"
|
||||
metrics "github.com/docker/go-metrics"
|
||||
"github.com/urfave/cli/v2"
|
||||
@@ -64,6 +65,19 @@ func init() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
cli.VersionPrinter = func(cliContext *cli.Context) {
|
||||
fmt.Println(cliContext.App.Name, version.Package, cliContext.App.Version)
|
||||
}
|
||||
|
||||
// Override the default flag descriptions for '--version' and '--help'
|
||||
// to align with other flags and start with uppercase.
|
||||
cli.VersionFlag = &cli.BoolFlag{
|
||||
Name: "version",
|
||||
Aliases: []string{"v"},
|
||||
Usage: "Print the version",
|
||||
|
||||
DisableDefaultText: true,
|
||||
}
|
||||
cli.HelpFlag = &cli.BoolFlag{
|
||||
Name: "help",
|
||||
Aliases: []string{"h"},
|
||||
@@ -132,6 +146,7 @@ func main() {
|
||||
app := cli.NewApp()
|
||||
app.Name = "containerd-stress"
|
||||
app.Description = "stress test a containerd daemon"
|
||||
app.Version = version.Version
|
||||
app.Flags = []cli.Flag{
|
||||
&cli.BoolFlag{
|
||||
Name: "debug",
|
||||
|
||||
Reference in New Issue
Block a user