forked from DataDog/datadog-agent
-
Notifications
You must be signed in to change notification settings - Fork 2
/
version.go
47 lines (41 loc) · 1.12 KB
/
version.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.
package app
import (
"fmt"
"runtime"
"github.com/StackVista/stackstate-agent/pkg/serializer"
"github.com/StackVista/stackstate-agent/pkg/version"
"github.com/fatih/color"
"github.com/spf13/cobra"
)
func init() {
AgentCmd.AddCommand(versionCmd)
}
var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the version info",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
if flagNoColor {
color.NoColor = true
}
av, _ := version.Agent()
meta := ""
if av.Meta != "" {
meta = fmt.Sprintf("- Meta: %s ", color.YellowString(av.Meta))
}
fmt.Fprintln(
color.Output,
fmt.Sprintf("Agent %s %s- Commit: %s - Serialization version: %s - Go version: %s",
color.CyanString(av.GetNumberAndPre()),
meta,
color.GreenString(av.Commit),
color.YellowString(serializer.AgentPayloadVersion),
color.RedString(runtime.Version()),
),
)
},
}