MCPcopy Index your code
hub / github.com/docker/cli / newTopCommand

Function newTopCommand

cli/command/container/top.go:23–46  ·  view source on GitHub ↗

newTopCommand creates a new cobra.Command for "docker container top",

(dockerCLI command.Cli)

Source from the content-addressed store, hash-verified

21
22// newTopCommand creates a new cobra.Command for "docker container top",
23func newTopCommand(dockerCLI command.Cli) *cobra.Command {
24 var opts topOptions
25
26 cmd := &cobra.Command{
27 Use: "top CONTAINER [ps OPTIONS]",
28 Short: "Display the running processes of a container",
29 Args: cli.RequiresMinArgs(1),
30 RunE: func(cmd *cobra.Command, args []string) error {
31 opts.container = args[0]
32 opts.args = args[1:]
33 return runTop(cmd.Context(), dockerCLI, &opts)
34 },
35 Annotations: map[string]string{
36 "aliases": "docker container top, docker top",
37 },
38 ValidArgsFunction: completion.ContainerNames(dockerCLI, false),
39 DisableFlagsInUseLine: true,
40 }
41
42 flags := cmd.Flags()
43 flags.SetInterspersed(false)
44
45 return cmd
46}
47
48func runTop(ctx context.Context, dockerCli command.Cli, opts *topOptions) error {
49 procList, err := dockerCli.Client().ContainerTop(ctx, opts.container, client.ContainerTopOptions{

Callers 1

newContainerCommandFunction · 0.85

Calls 1

runTopFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…