66 "github.com/docker/cli/cli"
77 "github.com/docker/cli/cli/command"
88 "github.com/docker/cli/cli/command/formatter"
9+ "github.com/docker/cli/opts"
910 "github.com/docker/docker/api/types"
10- "github.com/docker/docker/opts"
1111 "github.com/docker/docker/pkg/templates"
1212 "github.com/spf13/cobra"
1313 "golang.org/x/net/context"
@@ -26,27 +26,27 @@ type psOptions struct {
2626
2727// NewPsCommand creates a new cobra.Command for `docker ps`
2828func NewPsCommand (dockerCli * command.DockerCli ) * cobra.Command {
29- opts := psOptions {filter : opts .NewFilterOpt ()}
29+ options := psOptions {filter : opts .NewFilterOpt ()}
3030
3131 cmd := & cobra.Command {
3232 Use : "ps [OPTIONS]" ,
3333 Short : "List containers" ,
3434 Args : cli .NoArgs ,
3535 RunE : func (cmd * cobra.Command , args []string ) error {
36- return runPs (dockerCli , & opts )
36+ return runPs (dockerCli , & options )
3737 },
3838 }
3939
4040 flags := cmd .Flags ()
4141
42- flags .BoolVarP (& opts .quiet , "quiet" , "q" , false , "Only display numeric IDs" )
43- flags .BoolVarP (& opts .size , "size" , "s" , false , "Display total file sizes" )
44- flags .BoolVarP (& opts .all , "all" , "a" , false , "Show all containers (default shows just running)" )
45- flags .BoolVar (& opts .noTrunc , "no-trunc" , false , "Don't truncate output" )
46- flags .BoolVarP (& opts .nLatest , "latest" , "l" , false , "Show the latest created container (includes all states)" )
47- flags .IntVarP (& opts .last , "last" , "n" , - 1 , "Show n last created containers (includes all states)" )
48- flags .StringVarP (& opts .format , "format" , "" , "" , "Pretty-print containers using a Go template" )
49- flags .VarP (& opts .filter , "filter" , "f" , "Filter output based on conditions provided" )
42+ flags .BoolVarP (& options .quiet , "quiet" , "q" , false , "Only display numeric IDs" )
43+ flags .BoolVarP (& options .size , "size" , "s" , false , "Display total file sizes" )
44+ flags .BoolVarP (& options .all , "all" , "a" , false , "Show all containers (default shows just running)" )
45+ flags .BoolVar (& options .noTrunc , "no-trunc" , false , "Don't truncate output" )
46+ flags .BoolVarP (& options .nLatest , "latest" , "l" , false , "Show the latest created container (includes all states)" )
47+ flags .IntVarP (& options .last , "last" , "n" , - 1 , "Show n last created containers (includes all states)" )
48+ flags .StringVarP (& options .format , "format" , "" , "" , "Pretty-print containers using a Go template" )
49+ flags .VarP (& options .filter , "filter" , "f" , "Filter output based on conditions provided" )
5050
5151 return cmd
5252}
@@ -109,10 +109,10 @@ func buildContainerListOptions(opts *psOptions) (*types.ContainerListOptions, er
109109 return options , nil
110110}
111111
112- func runPs (dockerCli * command.DockerCli , opts * psOptions ) error {
112+ func runPs (dockerCli * command.DockerCli , options * psOptions ) error {
113113 ctx := context .Background ()
114114
115- listOptions , err := buildContainerListOptions (opts )
115+ listOptions , err := buildContainerListOptions (options )
116116 if err != nil {
117117 return err
118118 }
@@ -122,9 +122,9 @@ func runPs(dockerCli *command.DockerCli, opts *psOptions) error {
122122 return err
123123 }
124124
125- format := opts .format
125+ format := options .format
126126 if len (format ) == 0 {
127- if len (dockerCli .ConfigFile ().PsFormat ) > 0 && ! opts .quiet {
127+ if len (dockerCli .ConfigFile ().PsFormat ) > 0 && ! options .quiet {
128128 format = dockerCli .ConfigFile ().PsFormat
129129 } else {
130130 format = formatter .TableFormatKey
@@ -133,8 +133,8 @@ func runPs(dockerCli *command.DockerCli, opts *psOptions) error {
133133
134134 containerCtx := formatter.Context {
135135 Output : dockerCli .Out (),
136- Format : formatter .NewContainerFormat (format , opts .quiet , listOptions .Size ),
137- Trunc : ! opts .noTrunc ,
136+ Format : formatter .NewContainerFormat (format , options .quiet , listOptions .Size ),
137+ Trunc : ! options .noTrunc ,
138138 }
139139 return formatter .ContainerWrite (containerCtx , containers )
140140}
0 commit comments