Skip to content

Commit

Permalink
cmd/root: add more build information
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelPour committed Jul 13, 2023
1 parent 8cccef1 commit 72971b9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# For next release
* **Raphael Pour**
* cmd/root: add go version and last commit sha to the --version build information

*Not released yet*

# Major Release v1.0.0 (2023-07-12)
* **Raphael Pour**
* render:
Expand Down
15 changes: 13 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package cmd
import (
"fmt"
"os"
"runtime/debug"

"github.com/spf13/cobra"
)
Expand All @@ -29,8 +30,18 @@ var rootCmd = &cobra.Command{
Long: "Blogctl manages blog markdown-based posts database-less and generates a static website on-demand",
RunE: func(cmd *cobra.Command, args []string) error {
if Version {
fmt.Println("BuildVersion: ", BuildVersion)
fmt.Println("BuildDate: ", BuildDate)
fmt.Println("BuildVersion:", BuildVersion)
fmt.Println("BuildDate:", BuildDate)

if buildInfo, ok := debug.ReadBuildInfo(); ok {
fmt.Println("GoVersion:", buildInfo.GoVersion)
for _, pair := range buildInfo.Settings {
if pair.Key == "vcs.revision" {
fmt.Println("Commit:", pair.Value)
break
}
}
}
return nil
}
return cmd.Help()
Expand Down

0 comments on commit 72971b9

Please sign in to comment.