add changelog to --version
This commit is contained in:
parent
1921a74eec
commit
ced6809e1e
1 changed files with 5 additions and 1 deletions
|
|
@ -20,9 +20,13 @@ var Version = "DEV"
|
|||
// BuildDate is dynamically set at build time in the Makefile
|
||||
var BuildDate = "YYYY-MM-DD"
|
||||
|
||||
var versionOutput = ""
|
||||
|
||||
func init() {
|
||||
RootCmd.Version = fmt.Sprintf("%s (%s)", strings.TrimPrefix(Version, "v"), BuildDate)
|
||||
versionOutput = fmt.Sprintf("gh version %s\n%s\n", RootCmd.Version, changelogURL(RootCmd.Version))
|
||||
RootCmd.AddCommand(versionCmd)
|
||||
RootCmd.SetVersionTemplate(versionOutput)
|
||||
|
||||
RootCmd.PersistentFlags().StringP("repo", "R", "", "Select another repository using the `OWNER/REPO` format")
|
||||
RootCmd.PersistentFlags().Bool("help", false, "Show help for command")
|
||||
|
|
@ -57,7 +61,7 @@ var versionCmd = &cobra.Command{
|
|||
Use: "version",
|
||||
Hidden: true,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Printf("gh version %s\n%s\n", RootCmd.Version, changelogURL(RootCmd.Version))
|
||||
fmt.Printf(versionOutput)
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue