2024-06-17 18:59:20 +01:00
|
|
|
package printer
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
"text/tabwriter"
|
2024-08-13 14:53:26 +01:00
|
|
|
|
2024-08-23 02:35:30 +01:00
|
|
|
"codeflow.dananglin.me.uk/apollo/enbas/internal/info"
|
2024-06-17 18:59:20 +01:00
|
|
|
)
|
|
|
|
|
2024-08-13 14:53:26 +01:00
|
|
|
func (p Printer) PrintVersion(showFullVersion bool) {
|
2024-06-17 18:59:20 +01:00
|
|
|
if !showFullVersion {
|
2024-08-23 02:35:30 +01:00
|
|
|
printToStdout("Enbas " + info.BinaryVersion + "\n")
|
2024-06-17 18:59:20 +01:00
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
var builder strings.Builder
|
|
|
|
|
|
|
|
builder.WriteString(p.headerFormat("Enbas") + "\n\n")
|
|
|
|
|
|
|
|
tableWriter := tabwriter.NewWriter(&builder, 0, 4, 1, ' ', 0)
|
|
|
|
|
2024-08-23 02:35:30 +01:00
|
|
|
_, _ = tableWriter.Write([]byte(p.fieldFormat("Version:") + "\t" + info.BinaryVersion + "\n"))
|
|
|
|
_, _ = tableWriter.Write([]byte(p.fieldFormat("Git commit:") + "\t" + info.GitCommit + "\n"))
|
|
|
|
_, _ = tableWriter.Write([]byte(p.fieldFormat("Go version:") + "\t" + info.GoVersion + "\n"))
|
|
|
|
_, _ = tableWriter.Write([]byte(p.fieldFormat("Build date:") + "\t" + info.BuildTime + "\n"))
|
2024-06-17 18:59:20 +01:00
|
|
|
|
|
|
|
tableWriter.Flush()
|
|
|
|
|
|
|
|
printToStdout(builder.String())
|
|
|
|
}
|