summaryrefslogtreecommitdiff
path: root/cmd/podmanV2/images/images.go
blob: a1e56396a3260dde7cb0f02aaa473ff82c2cc0f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package images

import (
	"strings"

	"github.com/containers/libpod/cmd/podmanV2/registry"
	"github.com/containers/libpod/pkg/domain/entities"
	"github.com/spf13/cobra"
)

var (
	// podman _images_
	imagesCmd = &cobra.Command{
		Use:               strings.Replace(listCmd.Use, "list", "images", 1),
		Short:             listCmd.Short,
		Long:              listCmd.Long,
		PersistentPreRunE: preRunE,
		RunE:              images,
		Example:           strings.Replace(listCmd.Example, "podman image list", "podman images", -1),
	}

	imagesOpts = entities.ImageListOptions{}
)

func init() {
	registry.Commands = append(registry.Commands, registry.CliCommand{
		Mode:    []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
		Command: imagesCmd,
	})
	imagesCmd.SetHelpTemplate(registry.HelpTemplate())
	imagesCmd.SetUsageTemplate(registry.UsageTemplate())

	flags := imagesCmd.Flags()
	flags.BoolVarP(&imagesOpts.All, "all", "a", false, "Show all images (default hides intermediate images)")
	flags.BoolVar(&imagesOpts.Digests, "digests", false, "Show digests")
	flags.StringSliceVarP(&imagesOpts.Filter, "filter", "f", []string{}, "Filter output based on conditions provided (default [])")
	flags.StringVar(&imagesOpts.Format, "format", "", "Change the output format to JSON or a Go template")
	flags.BoolVarP(&imagesOpts.Noheading, "noheading", "n", false, "Do not print column headings")
	// TODO Need to learn how to deal with second name being a string instead of a char.
	// This needs to be "no-trunc, notruncate"
	flags.BoolVar(&imagesOpts.NoTrunc, "no-trunc", false, "Do not truncate output")
	flags.BoolVar(&imagesOpts.NoTrunc, "notruncate", false, "Do not truncate output")
	flags.BoolVarP(&imagesOpts.Quiet, "quiet", "q", false, "Display only image IDs")
	flags.StringVar(&imagesOpts.Sort, "sort", "created", "Sort by created, id, repository, size, or tag")
	flags.BoolVarP(&imagesOpts.History, "history", "", false, "Display the image name history")
}