Better aligment (#17)
This commit is contained in:
parent
64a70580db
commit
e16e5ca533
17
gauth.go
17
gauth.go
@ -126,14 +126,27 @@ func main() {
|
||||
prevTS := currentTS - 1
|
||||
nextTS := currentTS + 1
|
||||
|
||||
fmt.Println(" prev curr next")
|
||||
wordSize := 0
|
||||
for _, record := range cfg {
|
||||
actualSize := len([]rune(record[0]))
|
||||
if actualSize > wordSize {
|
||||
wordSize = actualSize
|
||||
}
|
||||
}
|
||||
|
||||
var header = "prev curr next"
|
||||
fmt.Println(leftPad(header, " ", wordSize+1))
|
||||
for _, record := range cfg {
|
||||
name := record[0]
|
||||
secret := normalizeSecret(record[1])
|
||||
prevToken := authCodeOrDie(secret, prevTS)
|
||||
currentToken := authCodeOrDie(secret, currentTS)
|
||||
nextToken := authCodeOrDie(secret, nextTS)
|
||||
fmt.Printf("%-10s %s %s %s\n", name, prevToken, currentToken, nextToken)
|
||||
fmt.Printf("%-*s %s %s %s\n", wordSize, name, prevToken, currentToken, nextToken)
|
||||
}
|
||||
fmt.Printf("[%-29s]\n", strings.Repeat("=", progress))
|
||||
}
|
||||
|
||||
func leftPad(s string, padStr string, pLen int) string {
|
||||
return strings.Repeat(padStr, pLen) + s
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user