Skip to content

Commit

Permalink
Sort commands by their name
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
saschagrunert committed Jul 2, 2024
1 parent 254cea5 commit 49938e2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/crictl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import (
"fmt"
"os"
"runtime"
"slices"
"sort"
"strings"
"time"

"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -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.",
Expand Down

0 comments on commit 49938e2

Please sign in to comment.