Skip to content

Commit a6b22d3

Browse files
authored
Add version command (open-telemetry#25)
Signed-off-by: Ashmita Bohara <[email protected]>
1 parent 7c67d1e commit a6b22d3

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
!.vscode/extensions.json
3232
*.code-workspace
3333

34+
### goland ###
35+
.idea
36+
3437
# End of https://www.toptal.com/developers/gitignore/api/go,vscode
3538

3639
/dist/

cmd/root.go

+12
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ var (
3030

3131
cfgFile string
3232
cfg = builder.DefaultConfig()
33+
34+
versionCmd = &cobra.Command{
35+
Use: "version",
36+
Short: "Version of opentelemetry-collector-builder",
37+
Long: "Prints the version of opentelemetry-collector-builder binary",
38+
Run: func(cmd *cobra.Command, args []string) {
39+
fmt.Println(version)
40+
},
41+
}
3342
)
3443

3544
// Execute is the main entrypoint for this application
@@ -68,6 +77,9 @@ func Execute() {
6877
cmd.Flags().StringVar(&cfg.Distribution.Go, "go", "/usr/bin/go", "The Go binary to use during the compilation phase")
6978
cmd.Flags().StringVar(&cfg.Distribution.Module, "module", "github.com/jpkroehling/opentelemetry-collector-builder", "The Go module for the new distribution")
7079

80+
// version of this binary
81+
cmd.AddCommand(versionCmd)
82+
7183
// tie Viper to flags
7284
if err := viper.BindPFlags(cmd.Flags()); err != nil {
7385
cfg.Logger.Error(err, "failed to bind flags")

0 commit comments

Comments
 (0)