Report error when desktop notifier is not supported

Fixes #155
This commit is contained in:
erroneousboat 2018-07-21 14:05:41 +02:00
parent 61561062ff
commit b6b0eed540

View File

@ -1,6 +1,7 @@
package context
import (
"errors"
"net/http"
_ "net/http/pprof"
"os"
@ -59,6 +60,17 @@ func CreateAppContext(flgConfig string, flgToken string, flgDebug bool) (*AppCon
}
}
// Create desktop notifier
var notify *notificator.Notificator
if config.Notify != "" {
notify = notificator.New(notificator.Options{AppName: "slack-term"})
if notify == nil {
return nil, errors.New(
"desktop notifications are not supported for your OS",
)
}
}
// Create Service
svc, err := service.NewSlackService(config)
if err != nil {
@ -105,6 +117,6 @@ func CreateAppContext(flgConfig string, flgToken string, flgDebug bool) (*AppCon
Config: config,
Debug: flgDebug,
Mode: CommandMode,
Notify: notificator.New(notificator.Options{AppName: "slack-term"}),
Notify: notify,
}, nil
}