Refactor formatter.
Signed-off-by: Daniel Nephin <dnephin@docker.com> Upstream-commit: c8336743a47216f87956b77449bd21714d3c45f1 Component: engine
This commit is contained in:
@ -106,27 +106,19 @@ func runPs(dockerCli *command.DockerCli, opts *psOptions) error {
|
||||
return err
|
||||
}
|
||||
|
||||
f := opts.format
|
||||
if len(f) == 0 {
|
||||
format := opts.format
|
||||
if len(format) == 0 {
|
||||
if len(dockerCli.ConfigFile().PsFormat) > 0 && !opts.quiet {
|
||||
f = dockerCli.ConfigFile().PsFormat
|
||||
format = dockerCli.ConfigFile().PsFormat
|
||||
} else {
|
||||
f = "table"
|
||||
format = "table"
|
||||
}
|
||||
}
|
||||
|
||||
psCtx := formatter.ContainerContext{
|
||||
Context: formatter.Context{
|
||||
Output: dockerCli.Out(),
|
||||
Format: f,
|
||||
Quiet: opts.quiet,
|
||||
Trunc: !opts.noTrunc,
|
||||
},
|
||||
Size: listOptions.Size,
|
||||
Containers: containers,
|
||||
containerCtx := formatter.Context{
|
||||
Output: dockerCli.Out(),
|
||||
Format: formatter.NewContainerFormat(format, opts.quiet, opts.size),
|
||||
Trunc: !opts.noTrunc,
|
||||
}
|
||||
|
||||
psCtx.Write()
|
||||
|
||||
return nil
|
||||
return formatter.ContainerWrite(containerCtx, containers)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user