aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman/container.go
blob: 8ad8d7a448d0dc5e8432960bc57b8247ad39d5d1 (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
47
48
49
50
51
52
53
54
package main

import (
	"strings"

	"github.com/containers/libpod/cmd/podman/cliconfig"
	"github.com/spf13/cobra"
)

var (
	containerDescription = "Manage containers"
	containerCommand     = cliconfig.PodmanCommand{
		Command: &cobra.Command{
			Use:              "container",
			Short:            "Manage Containers",
			Long:             containerDescription,
			TraverseChildren: true,
			RunE:             commandRunE(),
		},
	}

	listSubCommand  cliconfig.PsValues
	_listSubCommand = &cobra.Command{
		Use:     strings.Replace(_psCommand.Use, "ps", "list", 1),
		Args:    noSubArgs,
		Short:   _psCommand.Short,
		Long:    _psCommand.Long,
		Aliases: []string{"ls"},
		RunE: func(cmd *cobra.Command, args []string) error {
			listSubCommand.InputArgs = args
			listSubCommand.GlobalFlags = MainGlobalOpts
			return psCmd(&listSubCommand)
		},
		Example: strings.Replace(_psCommand.Example, "podman ps", "podman container list", -1),
	}

	// Commands that are universally implemented.
	containerCommands = []*cobra.Command{
		_containerExistsCommand,
		_inspectCommand,
		_listSubCommand,
	}
)

func init() {
	listSubCommand.Command = _listSubCommand
	psInit(&listSubCommand)

	containerCommand.AddCommand(containerCommands...)
	containerCommand.AddCommand(getContainerSubCommands()...)
	containerCommand.SetUsageTemplate(UsageTemplate())

	rootCmd.AddCommand(containerCommand.Command)
}