-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathcommand.go
More file actions
45 lines (38 loc) · 927 Bytes
/
Copy pathcommand.go
File metadata and controls
45 lines (38 loc) · 927 Bytes
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
package version
import (
"fmt"
"github.com/deepsourcelabs/cli/utils"
"github.com/deepsourcelabs/cli/version"
"github.com/spf13/cobra"
)
// Options holds the metadata.
type Options struct{}
// For testing. TODO: cleanup
var getBuildInfo = version.GetBuildInfo
// NewCmdVersion returns the current version of cli being used
func NewCmdVersion() *cobra.Command {
cmd := &cobra.Command{
Use: "version",
Short: "Get the version of the DeepSource CLI",
Args: utils.NoArgs,
Run: func(_ *cobra.Command, args []string) {
o := Options{}
fmt.Println(o.Run())
},
SilenceErrors: true,
SilenceUsage: true,
}
return cmd
}
// Validate impletments the Validate method for the ICommand interface.
func (Options) Validate() error {
return nil
}
// Run executest the command.
func (Options) Run() string {
buildInfo := getBuildInfo()
if buildInfo == nil {
return ""
}
return getBuildInfo().String()
}