diff --git a/cmd/api/out.go b/cmd/api/out.go index 6dd65d0..908accb 100755 --- a/cmd/api/out.go +++ b/cmd/api/out.go @@ -51,6 +51,13 @@ func OutTable(data interface{}, tmpl string) error { } return fmt.Sprintf(format, args...) }, + "pf": func(space int, decimals int, args ...interface{}) string { + format := "%" + strconv.Itoa(space) + "." + strconv.Itoa(decimals) + "f" + if space < 0 { + format = "%-" + strconv.Itoa(space) + "." + strconv.Itoa(decimals) + "f" + } + return fmt.Sprintf(format, args...) + }, "pt": func(value int64) string { return libol.PrettyTime(value) }, diff --git a/cmd/api/v5/qos.go b/cmd/api/v5/qos.go index 6af2fa2..feeb680 100644 --- a/cmd/api/v5/qos.go +++ b/cmd/api/v5/qos.go @@ -67,9 +67,9 @@ func (qr QosRule) Remove(c *cli.Context) error { func (qr QosRule) Tmpl() string { return `# total {{ len . }} -{{ps -15 "Name"}} {{ps -15 "Device"}} {{ps -15 "ip"}} {{ps -8 "InSpeed"}} +{{ps -28 "Name"}} {{ps -10 "Device"}} {{ps -15 "Ip"}} {{ps -8 "InSpeed"}} {{- range . }} -{{ps -15 .Name}} {{ps -15 .Device}} {{ps -15 .Ip}} {{pi -8 .InSpeed}} +{{ps -28 .Name}} {{ps -10 .Device}} {{ps -15 .Ip}} {{pf -8 2 .InSpeed}} {{- end }} ` }