Browse Source

do not split last column docker top

Victor Vieux 11 năm trước cách đây
mục cha
commit
fb4672c52c
3 tập tin đã thay đổi với 7 bổ sung3 xóa
  1. 1 1
      commands.go
  2. 1 1
      docs/sources/commandline/cli.rst
  3. 5 1
      server.go

+ 1 - 1
commands.go

@@ -682,7 +682,7 @@ func (cli *DockerCli) CmdInspect(args ...string) error {
 }
 
 func (cli *DockerCli) CmdTop(args ...string) error {
-	cmd := Subcmd("top", "CONTAINER", "Lookup the running processes of a container")
+	cmd := Subcmd("top", "CONTAINER [ps OPTIONS]", "Lookup the running processes of a container")
 	if err := cmd.Parse(args); err != nil {
 		return nil
 	}

+ 1 - 1
docs/sources/commandline/cli.rst

@@ -728,7 +728,7 @@ to the newly created container.
 
 ::
 
-    Usage: docker top CONTAINER
+    Usage: docker top CONTAINER [ps OPTIONS]
 
     Lookup the running processes of a container
 

+ 5 - 1
server.go

@@ -350,7 +350,11 @@ func (srv *Server) ContainerTop(name, ps_args string) (*APITop, error) {
 			}
 			// no scanner.Text because we skip container id
 			for scanner.Scan() {
-				words = append(words, scanner.Text())
+				if i != 0 && len(words) == len(procs.Titles) {
+					words[len(words)-1] = fmt.Sprintf("%s %s", words[len(words)-1], scanner.Text())
+				} else {
+					words = append(words, scanner.Text())
+				}
 			}
 			if i == 0 {
 				procs.Titles = words