mirror of
https://github.com/axllent/mailpit.git
synced 2025-09-16 09:26:37 +02:00
Feature: Add optional --no-release-check to version subcommand (#557)
This commit is contained in:
@@ -16,6 +16,7 @@ var versionCmd = &cobra.Command{
|
||||
Long: `Display the current version & update information (if available).`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
update, _ := cmd.Flags().GetBool("update")
|
||||
noReleaseCheck, _ := cmd.Flags().GetBool("no-release-check")
|
||||
|
||||
if update {
|
||||
// Update the application
|
||||
@@ -32,23 +33,25 @@ var versionCmd = &cobra.Command{
|
||||
fmt.Printf("%s %s compiled with %s on %s/%s\n",
|
||||
os.Args[0], config.Version, runtime.Version(), runtime.GOOS, runtime.GOARCH)
|
||||
|
||||
release, err := config.GHRUConfig.Latest()
|
||||
if err != nil {
|
||||
fmt.Printf("Error checking for latest release: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
if !noReleaseCheck {
|
||||
release, err := config.GHRUConfig.Latest()
|
||||
if err != nil {
|
||||
fmt.Printf("Error checking for latest release: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// The latest version is the same version
|
||||
if release.Tag == config.Version {
|
||||
os.Exit(0)
|
||||
}
|
||||
// The latest version is the same version
|
||||
if release.Tag == config.Version {
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// A newer release is available
|
||||
fmt.Printf(
|
||||
"\nUpdate available: %s\nRun `%s version -u` to update (requires read/write access to install directory).\n",
|
||||
release.Tag,
|
||||
os.Args[0],
|
||||
)
|
||||
// A newer release is available
|
||||
fmt.Printf(
|
||||
"\nUpdate available: %s\nRun `%s version -u` to update (requires read/write access to install directory).\n",
|
||||
release.Tag,
|
||||
os.Args[0],
|
||||
)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -57,4 +60,6 @@ func init() {
|
||||
|
||||
versionCmd.Flags().
|
||||
BoolP("update", "u", false, "update to latest version")
|
||||
versionCmd.Flags().
|
||||
Bool("no-release-check", false, "do not check online for the latest release version")
|
||||
}
|
||||
|
Reference in New Issue
Block a user