mirror of
https://github.com/containers/podman.git
synced 2025-10-26 02:35:43 +08:00
There exists a unit test to ensure that shell completion functions are defined. However there was no check about the quality of the provided shell completions. Lets change that. The idea is to create a general test that makes sure we are suggesting containers,pods,images... for the correct commands. This works by reading the command use line and checking for each arg if we provide the correct suggestions for this arg. It includes the following tests: - flag suggestions if [options] is set - container, pod, image, network, volume, registry completion - path completion for the appropriate arg KEYWORDS (`PATH`,`CONTEXT`,etc.) - no completion if there are no args - completion for more than one arg if it ends with `...]` The test does not cover completion values for flags and not every arg KEYWORD is supported. This is still a huge improvement and covers most use cases. This test spotted several inconsistencies between the completion and the command use line. All of them have been adjusted to make the test pass. The biggest advantage is that the completions always match the latest command changes. So if someone changes the arguments for a command this ensures that the completions must be adjusted. Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
48 lines
1.5 KiB
Go
48 lines
1.5 KiB
Go
package main
|
|
|
|
import (
|
|
"github.com/containers/podman/v2/cmd/podman/common"
|
|
"github.com/containers/podman/v2/cmd/podman/inspect"
|
|
"github.com/containers/podman/v2/cmd/podman/registry"
|
|
"github.com/containers/podman/v2/pkg/domain/entities"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var (
|
|
inspectDescription = `Displays the low-level information on an object identified by name or ID.
|
|
For more inspection options, see:
|
|
|
|
podman container inspect
|
|
podman image inspect
|
|
podman network inspect
|
|
podman pod inspect
|
|
podman volume inspect`
|
|
|
|
// Command: podman _inspect_ Object_ID
|
|
inspectCmd = &cobra.Command{
|
|
Use: "inspect [options] {CONTAINER|IMAGE|POD|NETWORK|VOLUME} [...]",
|
|
Short: "Display the configuration of object denoted by ID",
|
|
RunE: inspectExec,
|
|
Long: inspectDescription,
|
|
TraverseChildren: true,
|
|
ValidArgsFunction: common.AutocompleteInspect,
|
|
Example: `podman inspect fedora
|
|
podman inspect --type image fedora
|
|
podman inspect CtrID ImgID
|
|
podman inspect --format "imageId: {{.Id}} size: {{.Size}}" fedora`,
|
|
}
|
|
inspectOpts *entities.InspectOptions
|
|
)
|
|
|
|
func init() {
|
|
registry.Commands = append(registry.Commands, registry.CliCommand{
|
|
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
|
|
Command: inspectCmd,
|
|
})
|
|
inspectOpts = inspect.AddInspectFlagSet(inspectCmd)
|
|
}
|
|
|
|
func inspectExec(cmd *cobra.Command, args []string) error {
|
|
return inspect.Inspect(args, *inspectOpts)
|
|
}
|