Use go-humanize instead of lame hand-pluralization
This commit is contained in:
parent
3468393490
commit
b06a02f03c
7
Gopkg.lock
generated
7
Gopkg.lock
generated
|
@ -118,7 +118,10 @@
|
|||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/dustin/go-humanize"
|
||||
packages = ["."]
|
||||
packages = [
|
||||
".",
|
||||
"english"
|
||||
]
|
||||
revision = "bb3d318650d48840a39aa21a027c6630e198e626"
|
||||
|
||||
[[projects]]
|
||||
|
@ -596,6 +599,6 @@
|
|||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-digest = "33ea87ef02e7d2e7d83ee02261338e0e89fcd962aab275b2847e158a2631e0a5"
|
||||
inputs-digest = "e630b1d5be6ad07a0dd9c522a17fc628e34c0698e50f1546f0b600cdfdde11f3"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
|
|
@ -23,6 +23,8 @@ import (
|
|||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/dustin/go-humanize/english"
|
||||
|
||||
"github.com/pulumi/pulumi/pkg/apitype"
|
||||
"github.com/pulumi/pulumi/pkg/diag"
|
||||
"github.com/pulumi/pulumi/pkg/diag/colors"
|
||||
|
@ -157,7 +159,8 @@ func renderSummaryEvent(action apitype.UpdateKind, event engine.SummaryEventPayl
|
|||
fprintIgnoreError(out, opts.Color.Colorize(
|
||||
fmt.Sprintf("%sResources:%s\n", colors.SpecHeadline, colors.Reset)))
|
||||
fprintIgnoreError(out, opts.Color.Colorize(
|
||||
fmt.Sprintf(" %s%d %s%s\n", colors.Bold, changeCount, cmdutil.Plural("change", changeCount), colors.Reset)))
|
||||
fmt.Sprintf(" %s%d %s%s\n",
|
||||
colors.Bold, changeCount, english.PluralWord(changeCount, "change", ""), colors.Reset)))
|
||||
|
||||
var planTo string
|
||||
if event.IsPreview {
|
||||
|
|
|
@ -20,12 +20,13 @@ import (
|
|||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/dustin/go-humanize/english"
|
||||
|
||||
"github.com/pulumi/pulumi/pkg/diag"
|
||||
"github.com/pulumi/pulumi/pkg/diag/colors"
|
||||
"github.com/pulumi/pulumi/pkg/engine"
|
||||
"github.com/pulumi/pulumi/pkg/resource"
|
||||
"github.com/pulumi/pulumi/pkg/resource/deploy"
|
||||
"github.com/pulumi/pulumi/pkg/util/cmdutil"
|
||||
)
|
||||
|
||||
type Row interface {
|
||||
|
@ -336,19 +337,19 @@ func (data *resourceRowData) getInfoColumn() string {
|
|||
// If we are done, show a summary of how many messages were printed.
|
||||
if c := diagInfo.ErrorCount; c > 0 {
|
||||
appendDiagMessage(fmt.Sprintf("%d %s%s%s",
|
||||
c, colors.SpecError, cmdutil.Plural("error", c), colors.Reset))
|
||||
c, colors.SpecError, english.PluralWord(c, "error", ""), colors.Reset))
|
||||
}
|
||||
if c := diagInfo.WarningCount; c > 0 {
|
||||
appendDiagMessage(fmt.Sprintf("%d %s%s%s",
|
||||
c, colors.SpecWarning, cmdutil.Plural("warning", c), colors.Reset))
|
||||
c, colors.SpecWarning, english.PluralWord(c, "warning", ""), colors.Reset))
|
||||
}
|
||||
if c := diagInfo.InfoCount; c > 0 {
|
||||
appendDiagMessage(fmt.Sprintf("%d %s%s%s",
|
||||
c, colors.SpecInfo, cmdutil.Plural("message", c), colors.Reset))
|
||||
c, colors.SpecInfo, english.PluralWord(c, "message", ""), colors.Reset))
|
||||
}
|
||||
if c := diagInfo.DebugCount; c > 0 {
|
||||
appendDiagMessage(fmt.Sprintf("%d %s%s%s",
|
||||
c, colors.SpecDebug, cmdutil.Plural("debug", c), colors.Reset))
|
||||
c, colors.SpecDebug, english.PluralWord(c, "debug", ""), colors.Reset))
|
||||
}
|
||||
} else {
|
||||
// If we're not totally done, and we're in the tree-view, just print out the worst diagnostic next to the
|
||||
|
|
|
@ -67,11 +67,3 @@ func InitDiag(opts diag.FormatOptions) {
|
|||
contract.Assertf(snk == nil, "Cannot initialize diagnostics sink more than once")
|
||||
snk = diag.DefaultSink(os.Stdout, os.Stderr, opts)
|
||||
}
|
||||
|
||||
// Plural uses a dumb pluralization scheme, simply appending an "s", to the given string s if c is not 1.
|
||||
func Plural(s string, c int) string {
|
||||
if c != 1 {
|
||||
s += "s"
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue