Merge branch 'master' of github.com:luscis/openlan

This commit is contained in:
Daniel Ding
2024-04-02 14:18:52 +08:00
2 changed files with 9 additions and 2 deletions

View File

@@ -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)
},

View File

@@ -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 }}
`
}