diff --git a/Gopkg.lock b/Gopkg.lock index de60b921e..e3a6c4a57 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -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 diff --git a/pkg/backend/display/display.go b/pkg/backend/display/display.go index e75a33d55..9f9baef82 100644 --- a/pkg/backend/display/display.go +++ b/pkg/backend/display/display.go @@ -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 { diff --git a/pkg/backend/display/rows.go b/pkg/backend/display/rows.go index 5b3dde40d..963e96500 100644 --- a/pkg/backend/display/rows.go +++ b/pkg/backend/display/rows.go @@ -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 diff --git a/pkg/util/cmdutil/diag.go b/pkg/util/cmdutil/diag.go index f43982c2b..0df723ef2 100644 --- a/pkg/util/cmdutil/diag.go +++ b/pkg/util/cmdutil/diag.go @@ -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 -}