Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ var rootCmd = &cobra.Command{
},
}

// SetVersionInfo sets the version information for the root command.
func SetVersionInfo(version, buildDate string) {
rootCmd.Version = version
rootCmd.SetVersionTemplate(fmt.Sprintf("nomore403 version %s (built %s)\n", version, buildDate))
}

// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
Expand Down
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ package main

import "github.com/devploit/nomore403/cmd"

// Version and BuildDate are set via ldflags at build time.
var (
Version = "dev"
BuildDate = "unknown"
)

func main() {
cmd.SetVersionInfo(Version, BuildDate)
cmd.Execute()
}