Minor CLI improvements

- Show Emojis on non-Windows platforms, instead of just macOS

- Change help text for `pulumi logs` to clarify the logs are specific
  to a stack, not a project

- Display stack name when showing logs

- Have preamble text show to users for engine operations read a little
  nicer
This commit is contained in:
Matt Ellis 2018-04-25 16:49:58 -07:00
parent 1994c94b8b
commit 8f0dff3220
3 changed files with 22 additions and 17 deletions

View file

@ -29,7 +29,7 @@ func newLogsCmd() *cobra.Command {
logsCmd := &cobra.Command{
Use: "logs",
Short: "Show aggregated logs for a project",
Short: "Show aggregated logs for a stack",
Args: cmdutil.NoArgs,
Run: cmdutil.RunFunc(func(cmd *cobra.Command, args []string) error {
s, err := requireStack(stack, false)
@ -48,7 +48,8 @@ func newLogsCmd() *cobra.Command {
}
fmt.Printf(
colors.ColorizeText(colors.BrightMagenta+"Collecting logs since %s.\n\n"+colors.Reset),
colors.ColorizeText(colors.BrightMagenta+"Collecting logs for stack %s since %s.\n\n"+colors.Reset),
s.Name().String(),
startTime.Format(timeFormat),
)

View file

@ -473,24 +473,28 @@ func (b *cloudBackend) GetStackCrypter(stackRef backend.StackReference) (config.
return &cloudCrypter{backend: b, stack: stack}, nil
}
var (
updateTextMap = map[string]struct {
previewText string
text string
}{
string(client.UpdateKindUpdate): {"update of", "Updating"},
string(client.UpdateKindRefresh): {"refresh of", "Refreshing"},
string(client.UpdateKindDestroy): {"destroy of", "Destroying"},
string(client.UpdateKindImport): {"import to", "Importing into"},
}
)
func getActionLabel(key string, dryRun bool) string {
v := updateTextMap[key]
contract.Assert(v.previewText != "")
contract.Assert(v.text != "")
if dryRun {
return "Previewing"
return "Previewing " + v.previewText
}
switch key {
case string(client.UpdateKindUpdate):
return "Updating"
case string(client.UpdateKindRefresh):
return "Refreshing"
case string(client.UpdateKindDestroy):
return "Destroying"
case string(client.UpdateKindImport):
return "Importing"
}
contract.Failf("Should not get here.")
return ""
return v.text
}
type response string

View file

@ -15,7 +15,7 @@ import (
)
// Emoji controls whether emojis will by default be printed in the output.
var Emoji = (runtime.GOOS == "darwin")
var Emoji = (runtime.GOOS != "windows")
// EmojiOr returns the emoji string e if emojis are enabled, or the string or if emojis are disabled.
func EmojiOr(e, or string) string {