Browse code

do not split last column docker top

Victor Vieux authored on 2013/10/30 11:03:41
Showing 3 changed files
... ...
@@ -682,7 +682,7 @@ func (cli *DockerCli) CmdInspect(args ...string) error {
682 682
 }
683 683
 
684 684
 func (cli *DockerCli) CmdTop(args ...string) error {
685
-	cmd := Subcmd("top", "CONTAINER", "Lookup the running processes of a container")
685
+	cmd := Subcmd("top", "CONTAINER [ps OPTIONS]", "Lookup the running processes of a container")
686 686
 	if err := cmd.Parse(args); err != nil {
687 687
 		return nil
688 688
 	}
... ...
@@ -728,7 +728,7 @@ to the newly created container.
728 728
 
729 729
 ::
730 730
 
731
-    Usage: docker top CONTAINER
731
+    Usage: docker top CONTAINER [ps OPTIONS]
732 732
 
733 733
     Lookup the running processes of a container
734 734
 
... ...
@@ -350,7 +350,11 @@ func (srv *Server) ContainerTop(name, ps_args string) (*APITop, error) {
350 350
 			}
351 351
 			// no scanner.Text because we skip container id
352 352
 			for scanner.Scan() {
353
-				words = append(words, scanner.Text())
353
+				if i != 0 && len(words) == len(procs.Titles) {
354
+					words[len(words)-1] = fmt.Sprintf("%s %s", words[len(words)-1], scanner.Text())
355
+				} else {
356
+					words = append(words, scanner.Text())
357
+				}
354 358
 			}
355 359
 			if i == 0 {
356 360
 				procs.Titles = words