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

Function processOptions

cmd/nerdctl/container/container_list.go:61–124  ·  view source on GitHub ↗
(cmd *cobra.Command)

Source from the content-addressed store, hash-verified

59}
60
61func processOptions(cmd *cobra.Command) (types.ContainerListOptions, FormattingAndPrintingOptions, error) {
62 globalOptions, err := helpers.ProcessRootCmdFlags(cmd)
63 if err != nil {
64 return types.ContainerListOptions{}, FormattingAndPrintingOptions{}, err
65 }
66 all, err := cmd.Flags().GetBool("all")
67 if err != nil {
68 return types.ContainerListOptions{}, FormattingAndPrintingOptions{}, err
69 }
70 latest, err := cmd.Flags().GetBool("latest")
71 if err != nil {
72 return types.ContainerListOptions{}, FormattingAndPrintingOptions{}, err
73 }
74
75 lastN, err := cmd.Flags().GetInt("last")
76 if err != nil {
77 return types.ContainerListOptions{}, FormattingAndPrintingOptions{}, err
78 }
79 if lastN == -1 && latest {
80 lastN = 1
81 }
82
83 filters, err := cmd.Flags().GetStringSlice("filter")
84 if err != nil {
85 return types.ContainerListOptions{}, FormattingAndPrintingOptions{}, err
86 }
87
88 noTrunc, err := cmd.Flags().GetBool("no-trunc")
89 if err != nil {
90 return types.ContainerListOptions{}, FormattingAndPrintingOptions{}, err
91 }
92 trunc := !noTrunc
93
94 quiet, err := cmd.Flags().GetBool("quiet")
95 if err != nil {
96 return types.ContainerListOptions{}, FormattingAndPrintingOptions{}, err
97 }
98 format, err := cmd.Flags().GetString("format")
99 if err != nil {
100 return types.ContainerListOptions{}, FormattingAndPrintingOptions{}, err
101 }
102
103 size := false
104 if !quiet {
105 size, err = cmd.Flags().GetBool("size")
106 if err != nil {
107 return types.ContainerListOptions{}, FormattingAndPrintingOptions{}, err
108 }
109 }
110
111 return types.ContainerListOptions{
112 GOptions: globalOptions,
113 All: all,
114 LastN: lastN,
115 Truncate: trunc,
116 Size: size || (format == "wide" && !quiet),
117 Filters: filters,
118 }, FormattingAndPrintingOptions{

Callers 1

psActionFunction · 0.85

Calls 1

ProcessRootCmdFlagsFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…