mirror of
https://github.com/charmbracelet/glow
synced 2024-12-14 14:12:27 +00:00
Enable version command for release builds
This commit is contained in:
parent
c31c06a793
commit
2bae07eac9
1 changed files with 14 additions and 3 deletions
17
main.go
17
main.go
|
@ -17,7 +17,12 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
Version = ""
|
||||
CommitSHA = ""
|
||||
|
||||
readmeNames = []string{"README.md", "README"}
|
||||
style string
|
||||
width uint
|
||||
|
||||
rootCmd = &cobra.Command{
|
||||
Use: "gold SOURCE",
|
||||
|
@ -26,9 +31,6 @@ var (
|
|||
SilenceUsage: false,
|
||||
RunE: execute,
|
||||
}
|
||||
|
||||
style string
|
||||
width uint
|
||||
)
|
||||
|
||||
type Source struct {
|
||||
|
@ -135,6 +137,15 @@ func main() {
|
|||
}
|
||||
|
||||
func init() {
|
||||
if CommitSHA != "" {
|
||||
vt := rootCmd.VersionTemplate()
|
||||
rootCmd.SetVersionTemplate(vt[:len(vt)-1] + " (" + CommitSHA + ")\n")
|
||||
}
|
||||
if Version == "" {
|
||||
Version = "unknown (built from source)"
|
||||
}
|
||||
rootCmd.Version = Version
|
||||
|
||||
rootCmd.Flags().StringVarP(&style, "style", "s", "dark", "style name or JSON path")
|
||||
rootCmd.Flags().UintVarP(&width, "width", "w", 100, "word-wrap at width")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue