Example #1
0
//Command prettifies the command that starts the container
func (c *ContainerFormatter) Command() string {
	c.addHeader(commandHeader)
	command := c.c.Command
	if c.trunc {
		command = strutil.Resize(command, 30)
	}
	return command
}
Example #2
0
// String returns the string formated representation of the cell
func (c *Cell) String() string {
	if c.Data == nil {
		return strutil.PadLeft(" ", int(c.Width), ' ')
	}
	s := fmt.Sprintf("%v", c.Data)
	switch {
	case c.Width > 0 && c.Wrap:
		return wordwrap.WrapString(s, c.Width)
	case c.Width > 0:
		return strutil.Resize(s, c.Width)
	}
	return s
}
Example #3
0
// String returns the string formated representation of the cell
func (c *Cell) String() string {
	if c.Data == nil {
		return strutil.PadLeft(" ", int(c.Width), ' ')
	}
	s := fmt.Sprintf("%v", c.Data)
	if c.Width > 0 {
		if c.Wrap && uint(len(s)) > c.Width {
			return wordwrap.WrapString(s, c.Width)
		} else {
			return strutil.Resize(s, c.Width, c.RightAlign)
		}
	}
	return s
}
Example #4
0
File: stats.go Project: hako/dry
//Render container stats
func (r *statsRenderer) Render() string {
	s := r.stats
	buf := bytes.NewBufferString("")
	w := tabwriter.NewWriter(buf, 22, 0, 1, ' ', 0)
	io.WriteString(w, "<green>CONTAINER\tCOMMAND\t%%CPU\tMEM USAGE / LIMIT\t%%MEM\tNET I/O\tBLOCK I/O</>\n")
	io.WriteString(
		w,
		fmt.Sprintf("<white>%s\t%s\t%.2f\t%s / %s\t%.2f\t%s / %s\t%s / %s</>\n",
			s.CID,
			strutil.Resize(s.Command, 20),
			s.CPUPercentage,
			units.HumanSize(s.Memory), units.HumanSize(s.MemoryLimit),
			s.MemoryPercentage,
			units.HumanSize(s.NetworkRx), units.HumanSize(s.NetworkTx),
			units.HumanSize(s.BlockRead), units.HumanSize(s.BlockWrite)))
	w.Flush()
	return buf.String()
}