diff options
| author | Paul Bütow <pbuetow@mimecast.com> | 2020-01-20 18:41:05 +0000 |
|---|---|---|
| committer | Paul Bütow <pbuetow@mimecast.com> | 2020-01-21 14:35:23 +0000 |
| commit | c128865c4c7411c29a59fca9a3a2f95537686d7b (patch) | |
| tree | 193bccc70d942c8b70cc93fae2670263701e43aa /internal/version | |
| parent | 3755a9911ecb05886577095f2b8cc8b9e4066a3a (diff) | |
Move commands to cmd/ and move internal dependencies to internal/
Diffstat (limited to 'internal/version')
| -rw-r--r-- | internal/version/version.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/internal/version/version.go b/internal/version/version.go new file mode 100644 index 0000000..d036a68 --- /dev/null +++ b/internal/version/version.go @@ -0,0 +1,40 @@ +package version + +import ( + "fmt" + "os" + + "github.com/mimecast/dtail/internal/color" +) + +// Name of DTail. +const Name = "DTail" + +// Version of DTail. +const Version = "1.1.0" + +// Additional information. +const Additional = "develop" + +// String representation of the DTail version. +func String() string { + return fmt.Sprintf("%s v%v %s", Name, Version, Additional) +} + +// PaintedString is a prettier string representation of the DTail version. +func PaintedString() string { + if !color.Colored { + 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 %s", name, version, descr) +} + +// PrintAndExit prints the program version and exists. +func PrintAndExit() { + fmt.Println(PaintedString()) + os.Exit(0) +} |
