Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions cmd/containerd-stress/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
}
}

Expand Down Expand Up @@ -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",
Expand Down
7 changes: 7 additions & 0 deletions cmd/containerd/command/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down
7 changes: 7 additions & 0 deletions cmd/ctr/app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down
7 changes: 6 additions & 1 deletion pkg/shim/shim.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading