MCPcopy Index your code
hub / github.com/docker/cli / newHistoryCommand

Function newHistoryCommand

cli/command/image/history.go:28–57  ·  view source on GitHub ↗

newHistoryCommand creates a new "docker image history" command.

(dockerCLI command.Cli)

Source from the content-addressed store, hash-verified

26
27// newHistoryCommand creates a new "docker image history" command.
28func newHistoryCommand(dockerCLI command.Cli) *cobra.Command {
29 var opts historyOptions
30
31 cmd := &cobra.Command{
32 Use: "history [OPTIONS] IMAGE",
33 Short: "Show the history of an image",
34 Args: cli.ExactArgs(1),
35 RunE: func(cmd *cobra.Command, args []string) error {
36 opts.image = args[0]
37 return runHistory(cmd.Context(), dockerCLI, opts)
38 },
39 ValidArgsFunction: completion.ImageNames(dockerCLI, 1),
40 Annotations: map[string]string{
41 "aliases": "docker image history, docker history",
42 },
43 DisableFlagsInUseLine: true,
44 }
45
46 flags := cmd.Flags()
47
48 flags.BoolVarP(&opts.human, "human", "H", true, "Print sizes and dates in human readable format")
49 flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Only show image IDs")
50 flags.BoolVar(&opts.noTrunc, "no-trunc", false, "Don't truncate output")
51 flags.StringVar(&opts.format, "format", "", flagsHelper.FormatHelp)
52 flags.StringVar(&opts.platform, "platform", "", `Show history for the given platform. Formatted as "os[/arch[/variant]]" (e.g., "linux/amd64")`)
53 _ = flags.SetAnnotation("platform", "version", []string{"1.48"})
54
55 _ = cmd.RegisterFlagCompletionFunc("platform", completion.Platforms())
56 return cmd
57}
58
59func runHistory(ctx context.Context, dockerCli command.Cli, opts historyOptions) error {
60 var options []client.ImageHistoryOption

Callers 3

newImageCommandFunction · 0.85

Calls 1

runHistoryFunction · 0.85

Tested by 2

Used in the wild real call sites across dependent graphs

searching dependent graphs…