newInspectCommand creates a new cobra.Command for `docker container inspect`
(dockerCLI command.Cli)
| 23 | |
| 24 | // newInspectCommand creates a new cobra.Command for `docker container inspect` |
| 25 | func newInspectCommand(dockerCLI command.Cli) *cobra.Command { |
| 26 | var opts inspectOptions |
| 27 | |
| 28 | cmd := &cobra.Command{ |
| 29 | Use: "inspect [OPTIONS] CONTAINER [CONTAINER...]", |
| 30 | Short: "Display detailed information on one or more containers", |
| 31 | Args: cli.RequiresMinArgs(1), |
| 32 | RunE: func(cmd *cobra.Command, args []string) error { |
| 33 | opts.refs = args |
| 34 | return runInspect(cmd.Context(), dockerCLI, opts) |
| 35 | }, |
| 36 | ValidArgsFunction: completion.ContainerNames(dockerCLI, true), |
| 37 | DisableFlagsInUseLine: true, |
| 38 | } |
| 39 | |
| 40 | flags := cmd.Flags() |
| 41 | flags.StringVarP(&opts.format, "format", "f", "", flagsHelper.InspectFormatHelp) |
| 42 | flags.BoolVarP(&opts.size, "size", "s", false, "Display total file sizes") |
| 43 | |
| 44 | return cmd |
| 45 | } |
| 46 | |
| 47 | func runInspect(ctx context.Context, dockerCLI command.Cli, opts inspectOptions) error { |
| 48 | apiClient := dockerCLI.Client() |
no test coverage detected
searching dependent graphs…