diff options
| author | Paul Buetow <pbuetow@mimecast.com> | 2021-10-21 21:28:49 +0300 |
|---|---|---|
| committer | Paul Buetow <pbuetow@mimecast.com> | 2021-10-21 21:28:49 +0300 |
| commit | f4207a55f71bfbcfdc532d5cdd3befaa3474a157 (patch) | |
| tree | ea5e4a2d2a67035f645bdee496ae55a52034178a /internal/version | |
| parent | d80d6070557e3a800e3a54967af9eced518f116b (diff) | |
| parent | 739205206d63bf42f4e843b39d04d4c8cd8207c3 (diff) | |
merge develop
Diffstat (limited to 'internal/version')
| -rw-r--r-- | internal/version/version.go | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/internal/version/version.go b/internal/version/version.go index 3c31059..68b9e6e 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -5,38 +5,50 @@ import ( "os" "github.com/mimecast/dtail/internal/color" + "github.com/mimecast/dtail/internal/config" + "github.com/mimecast/dtail/internal/protocol" ) const ( // Name of DTail. Name string = "DTail" // Version of DTail. - Version string = "3.3.1" + Version string = "4.0.0-RC1" // Additional information for DTail - Additional string = "" - // ProtocolCompat -ibility version. - ProtocolCompat string = "3" + Additional string = "Have a lot of fun!" ) // String representation of the DTail version. func String() string { - return fmt.Sprintf("%s %v Protocol %s %s", Name, Version, ProtocolCompat, Additional) + return fmt.Sprintf("%s %v Protocol %s %s", Name, Version, + protocol.ProtocolCompat, Additional) } // PaintedString is a prettier string representation of the DTail version. func PaintedString() string { - if !color.Colored { + if !config.Client.TermColorsEnable { return String() } - name := color.Paint(color.Yellow, Name) - version := color.Paint(color.Blue, Version) - descr := color.Paint(color.Green, Additional) - return fmt.Sprintf("%s %v Protocol %s %s", name, version, ProtocolCompat, descr) + name := color.PaintStrWithAttr(fmt.Sprintf(" %s ", Name), + color.FgYellow, color.BgBlue, color.AttrBold) + version := color.PaintStrWithAttr(fmt.Sprintf(" %s ", Version), + color.FgBlue, color.BgYellow, color.AttrBold) + protocol := color.PaintStr(fmt.Sprintf(" Protocol %s ", protocol.ProtocolCompat), + color.FgBlack, color.BgGreen) + additional := color.PaintStrWithAttr(fmt.Sprintf(" %s ", Additional), + color.FgWhite, color.BgMagenta, color.AttrUnderline) + + return fmt.Sprintf("%s%v%s%s", name, version, protocol, additional) +} + +// Print the version. +func Print() { + fmt.Println(PaintedString()) } // PrintAndExit prints the program version and exists. func PrintAndExit() { - fmt.Println(PaintedString()) + Print() os.Exit(0) } |
