forked from toolshed/abra
feat: added util formatting for the cil
This commit is contained in:
30
cli/formatter.go
Normal file
30
cli/formatter.go
Normal file
@ -0,0 +1,30 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/docker/cli/cli/command/formatter"
|
||||
"github.com/docker/go-units"
|
||||
)
|
||||
|
||||
func shortenID(str string) string {
|
||||
return str[:12]
|
||||
}
|
||||
|
||||
func truncate(str string) string {
|
||||
return fmt.Sprintf(`"%s"`, formatter.Ellipsis(str, 19))
|
||||
}
|
||||
|
||||
// removeSha remove image sha from a string that are added in some docker outputs
|
||||
func removeSha(str string) string {
|
||||
return strings.Split(str, "@")[0]
|
||||
}
|
||||
|
||||
// humanDuration from docker/cli RunningFor() to be accessable outside of the class
|
||||
func humanDuration(timestamp int64) string {
|
||||
date := time.Unix(timestamp, 0)
|
||||
now := time.Now().UTC()
|
||||
return units.HumanDuration(now.Sub(date)) + " ago"
|
||||
}
|
Reference in New Issue
Block a user