diff --git a/cmd/containerd-stress/main.go b/cmd/containerd-stress/main.go index 5739b0f2de4c5..f8d0d0949ee72 100644 --- a/cmd/containerd-stress/main.go +++ b/cmd/containerd-stress/main.go @@ -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,10 +65,25 @@ 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"}, Usage: "Show help", + + DisableDefaultText: true, } } @@ -130,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", diff --git a/cmd/containerd/command/main.go b/cmd/containerd/command/main.go index c4d58c1322f72..94d590af2efb7 100644 --- a/cmd/containerd/command/main.go +++ b/cmd/containerd/command/main.go @@ -57,15 +57,22 @@ func init() { cli.VersionPrinter = func(cliContext *cli.Context) { fmt.Println(cliContext.App.Name, version.Package, cliContext.App.Version, version.Revision) } + + // 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"}, Usage: "Show help", + + DisableDefaultText: true, } } diff --git a/cmd/ctr/app/main.go b/cmd/ctr/app/main.go index 13ec27635df57..d03ba9b94a2f9 100644 --- a/cmd/ctr/app/main.go +++ b/cmd/ctr/app/main.go @@ -55,15 +55,22 @@ func init() { 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"}, Usage: "Show help", + + DisableDefaultText: true, } } diff --git a/pkg/shim/shim.go b/pkg/shim/shim.go index cc8da6f765478..2f93203c8f7dc 100644 --- a/pkg/shim/shim.go +++ b/pkg/shim/shim.go @@ -139,7 +139,12 @@ const ( func parseFlags() { flag.BoolVar(&debugFlag, "debug", false, "enable debug output in logs") - flag.BoolVar(&versionFlag, "v", false, "show the shim version and exit") + + // short + long form. omitting the usage (description) of the short-form + // to group it with the long form. + flag.BoolVar(&versionFlag, "v", false, "") + flag.BoolVar(&versionFlag, "version", false, "show the shim version and exit") + // "info" is not a subcommand, because old shims produce very confusing errors for unknown subcommands // https://github.com/containerd/containerd/pull/8509#discussion_r1210021403 flag.BoolVar(&infoFlag, "info", false, "get the option protobuf from stdin, print the shim info protobuf to stdout, and exit")