From d898927a366ad7e5340447cd4df2cc3db04b2023 Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Tue, 2 Jul 2024 12:43:14 +0200 Subject: [PATCH] Sort commands by their name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The command list of `crictl` is now sorted alphabetically: ``` … COMMANDS: attach Attach to a running container checkpoint Checkpoint one or more running containers completion Output shell completion code config Get and set crictl client configuration options create Create a new container events, event Stream the events of containers exec Run a command in a running container imagefsinfo Return image filesystem info images, image, img List images info Display information of the container runtime inspect Display the status of one or more containers inspecti Return the status of one or more images inspectp Display the status of one or more pods logs Fetch the logs of a container metricsp List pod metrics. Metrics are unstructured key/value pairs gathered by CRI meant to replace cAdvisor's /metrics/cadvisor endpoint. pods List pods port-forward Forward local port to a pod ps List containers pull Pull an image from a registry rm Remove one or more containers rmi Remove one or more images rmp Remove one or more pods run Run a new container inside a sandbox runp Run a new pod runtime-config Retrieve the container runtime configuration start Start one or more created containers stats List container(s) resource usage statistics statsp List pod statistics. Stats represent a structured API that will fulfill the Kubelet's /stats/summary endpoint. stop Stop one or more running containers stopp Stop one or more running pods update Update one or more running containers version Display runtime version information help, h Shows a list of commands or help for one command … ``` Signed-off-by: Sascha Grunert --- cmd/crictl/main.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/crictl/main.go b/cmd/crictl/main.go index fce4dee4f8..c797d757d8 100644 --- a/cmd/crictl/main.go +++ b/cmd/crictl/main.go @@ -22,7 +22,9 @@ import ( "fmt" "os" "runtime" + "slices" "sort" + "strings" "time" "github.com/sirupsen/logrus" @@ -210,6 +212,8 @@ func main() { eventsCommand, } + slices.SortFunc(app.Commands, func(a, b *cli.Command) int { return strings.Compare(a.Name, b.Name) }) + runtimeEndpointUsage := fmt.Sprintf("Endpoint of CRI container runtime "+ "service (default: uses in order the first successful one of %v). "+ "Default is now deprecated and the endpoint should be set instead.",