diff --git a/README.md b/README.md index 56fc4f2..6d26300 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Available Commands: list Display your firewall's allowed IPs. sync Synchronize local config with firewall update Allow a new IP on the firewall. - version Display version information + version Display version information and check for updates. ``` ## Supported Providers diff --git a/main.go b/main.go index 5cd1173..57f9875 100644 --- a/main.go +++ b/main.go @@ -25,10 +25,13 @@ connecting from and keeps your development VM firewall rule up to date with that versionCmd := &cobra.Command{ Use: "version", - Short: "Display version information", + Short: "Display version information and check for updates", Run: func(cmd *cobra.Command, args []string) { fmt.Println(version) }, + PostRunE: func(cmd *cobra.Command, args []string) error { + return notifyIfUpdateAvailable() + }, } // disable the default command that generates shell completions @@ -45,12 +48,6 @@ connecting from and keeps your development VM firewall rule up to date with that fmt.Fprintf(os.Stderr, "Error running command: %q\n", err) os.Exit(1) } - - err := notifyIfUpdateAvailable() - if err != nil { - fmt.Fprintf(os.Stderr, "Error checking for updates: %q\n", err) - os.Exit(1) - } } func notifyIfUpdateAvailable() error {