Merge branch 'master' into view-the-current-state

This commit is contained in:
Toshiya Doi 2020-03-18 08:51:04 +09:00
commit 7ceffd0827
14 changed files with 594 additions and 194 deletions

View file

@ -2,6 +2,7 @@ package utils
import (
"fmt"
"strings"
"time"
"github.com/briandowns/spinner"
@ -54,6 +55,19 @@ func FuzzyAgo(ago time.Duration) string {
return fmtDuration(int(ago.Hours()/24/365), "year")
}
func Humanize(s string) string {
// Replaces - and _ with spaces.
replace := "_-"
h := func(r rune) rune {
if strings.ContainsRune(replace, r) {
return ' '
}
return r
}
return strings.Map(h, s)
}
func Spinner() *spinner.Spinner {
return spinner.New(spinner.CharSets[11], 400*time.Millisecond)
}