@@ -10,15 +10,31 @@ import (
1010)
1111
1212func main () {
13- isProduction := os .Getenv ("APP_ENV" ) != "production"
14- update .RunWhileCheckingForUpdate (isProduction , func () {
15- if cmd , err := command .RootCmd .ExecuteC (); err != nil {
16- fmt .Fprintln (os .Stderr , err )
17- _ , isFlagError := err .(command.FlagError )
18- if isFlagError || strings .HasPrefix (err .Error (), "unknown command " ) {
19- fmt .Fprintln (os .Stderr , cmd .UsageString ())
20- }
21- os .Exit (1 )
13+ alertMsgChan := make (chan * string )
14+ go updateInBackground (alertMsgChan )
15+
16+ if cmd , err := command .RootCmd .ExecuteC (); err != nil {
17+ fmt .Fprintln (os .Stderr , err )
18+ _ , isFlagError := err .(command.FlagError )
19+ if isFlagError || strings .HasPrefix (err .Error (), "unknown command " ) {
20+ fmt .Fprintln (os .Stderr , cmd .UsageString ())
2221 }
23- })
22+ os .Exit (1 )
23+ }
24+
25+ alertMsg := <- alertMsgChan
26+ if alertMsg != nil {
27+ fmt .Fprintf (os .Stderr , * alertMsg )
28+ }
29+ }
30+
31+ func updateInBackground (alertMsgChan chan * string ) {
32+ client , err := command .BasicClient ()
33+ if err != nil {
34+ alertMsgChan <- nil
35+ return
36+ }
37+
38+ alertMsg := update .UpdateMessage (client )
39+ alertMsgChan <- alertMsg
2440}
0 commit comments