Skip to content

Commit

Permalink
Fixes google#77: Implemented column headers in table
Browse files Browse the repository at this point in the history
  • Loading branch information
yashLadha committed Apr 23, 2019
1 parent 036f72c commit 5397580
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,29 +106,48 @@ func processes() {

}

// Print header for all the entries
printColumnHeaders()

for _, p := range ps {
buf := bytes.NewBuffer(nil)
pid := strconv.Itoa(p.PID)
fmt.Fprint(buf, pad(pid, maxPID))
fmt.Fprint(buf, " ")
fmt.Fprint(buf, "\t")
ppid := strconv.Itoa(p.PPID)
fmt.Fprint(buf, pad(ppid, maxPPID))
fmt.Fprint(buf, " ")
fmt.Fprint(buf, "\t")
fmt.Fprint(buf, pad(p.Exec, maxExec))
if p.Agent {
fmt.Fprint(buf, "*")
} else {
fmt.Fprint(buf, " ")
fmt.Fprint(buf, "\t")
}
fmt.Fprint(buf, " ")
fmt.Fprint(buf, "\t")
fmt.Fprint(buf, pad(p.BuildVersion, maxVersion))
fmt.Fprint(buf, " ")
fmt.Fprint(buf, "\t")
fmt.Fprint(buf, p.Path)
fmt.Fprintln(buf)
buf.WriteTo(os.Stdout)
}
}

func printColumnHeaders() {
buf := bytes.NewBuffer(nil)
fmt.Fprint(buf, "maxPID")
fmt.Fprint(buf, "\t")
fmt.Fprint(buf, "maxPPID")
fmt.Fprint(buf, "\t")
fmt.Fprint(buf, "maxExec")
fmt.Fprint(buf, "\t\t\t")
fmt.Fprint(buf, "maxVersion")
fmt.Fprint(buf, "\t")
fmt.Fprint(buf, "path")
fmt.Fprint(buf, "\t")
fmt.Fprintln(buf)
buf.WriteTo(os.Stdout)
}

func processInfo(pid int) {
p, err := process.NewProcess(int32(pid))
if err != nil {
Expand Down

0 comments on commit 5397580

Please sign in to comment.