github.com/opentofu/opentofu@v1.7.1/internal/command/format/format.go (about) 1 // Copyright (c) The OpenTofu Authors 2 // SPDX-License-Identifier: MPL-2.0 3 // Copyright (c) 2023 HashiCorp, Inc. 4 // SPDX-License-Identifier: MPL-2.0 5 6 // Package format contains helpers for formatting various OpenTofu 7 // structures for human-readabout output. 8 // 9 // This package is used by the official OpenTofu CLI in formatting any 10 // output and is exported to encourage non-official frontends to mimic the 11 // output formatting as much as possible so that text formats of OpenTofu 12 // structures have a consistent look and feel. 13 package format 14 15 import "github.com/opentofu/opentofu/internal/plans" 16 17 // DiffActionSymbol returns a string that, once passed through a 18 // colorstring.Colorize, will produce a result that can be written 19 // to a terminal to produce a symbol made of three printable 20 // characters, possibly interspersed with VT100 color codes. 21 func DiffActionSymbol(action plans.Action) string { 22 switch action { 23 case plans.DeleteThenCreate: 24 return "[red]-[reset]/[green]+[reset]" 25 case plans.CreateThenDelete: 26 return "[green]+[reset]/[red]-[reset]" 27 case plans.Create: 28 return " [green]+[reset]" 29 case plans.Delete: 30 return " [red]-[reset]" 31 case plans.Read: 32 return " [cyan]<=[reset]" 33 case plans.Update: 34 return " [yellow]~[reset]" 35 case plans.NoOp: 36 return " " 37 case plans.Forget: 38 return " [red].[reset]" 39 default: 40 return " ?" 41 } 42 }