Skip to content

Commit

Permalink
Add version command (#25)
Browse files Browse the repository at this point in the history
Signed-off-by: Ashmita Bohara <[email protected]>
  • Loading branch information
Ashmita152 authored Mar 22, 2021
1 parent 7c67d1e commit a6b22d3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
!.vscode/extensions.json
*.code-workspace

### goland ###
.idea

# End of https://www.toptal.com/developers/gitignore/api/go,vscode

/dist/
Expand Down
12 changes: 12 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ var (

cfgFile string
cfg = builder.DefaultConfig()

versionCmd = &cobra.Command{
Use: "version",
Short: "Version of opentelemetry-collector-builder",
Long: "Prints the version of opentelemetry-collector-builder binary",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(version)
},
}
)

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

// version of this binary
cmd.AddCommand(versionCmd)

// tie Viper to flags
if err := viper.BindPFlags(cmd.Flags()); err != nil {
cfg.Logger.Error(err, "failed to bind flags")
Expand Down

0 comments on commit a6b22d3

Please sign in to comment.