MCPcopy Create free account
hub / github.com/containerd/nerdctl / PsCommand

Function PsCommand

cmd/nerdctl/container/container_list.go:36–59  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34)
35
36func PsCommand() *cobra.Command {
37 var cmd = &cobra.Command{
38 Use: "ps",
39 Args: cobra.NoArgs,
40 Short: "List containers",
41 RunE: psAction,
42 SilenceUsage: true,
43 SilenceErrors: true,
44 }
45 cmd.Flags().BoolP("all", "a", false, "Show all containers (default shows just running)")
46 cmd.Flags().IntP("last", "n", -1, "Show n last created containers (includes all states)")
47 cmd.Flags().BoolP("latest", "l", false, "Show the latest created container (includes all states)")
48 cmd.Flags().Bool("no-trunc", false, "Don't truncate output")
49 cmd.Flags().BoolP("quiet", "q", false, "Only display container IDs")
50 cmd.Flags().BoolP("size", "s", false, "Display total file sizes")
51
52 // Alias "-f" is reserved for "--filter"
53 cmd.Flags().String("format", "", "Format the output using the given Go template, e.g, '{{json .}}', 'wide'")
54 cmd.RegisterFlagCompletionFunc("format", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
55 return []string{"json", "table", "wide"}, cobra.ShellCompDirectiveNoFileComp
56 })
57 cmd.Flags().StringSliceP("filter", "f", nil, "Filter matches containers based on given conditions. When specifying the condition 'status', it filters all containers")
58 return cmd
59}
60
61func processOptions(cmd *cobra.Command) (types.ContainerListOptions, FormattingAndPrintingOptions, error) {
62 globalOptions, err := helpers.ProcessRootCmdFlags(cmd)

Callers 2

newAppFunction · 0.92
listCommandFunction · 0.85

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…