Check for slack_token parameter before launch

This commit is contained in:
Gabor Takacs 2016-10-18 17:55:37 +02:00
parent 0ba1d964ec
commit 43ea994b9e
3 changed files with 7 additions and 2 deletions

View File

@ -21,7 +21,7 @@ Getting started
```javascript
{
"slack_token": "yourslacktokenhere"
"slack_token": "yourslacktokenhere",
// add the following to use light theme, default is dark
"theme": "light"

View File

@ -2,6 +2,7 @@ package config
import (
"encoding/json"
"errors"
"os"
"github.com/gizak/termui"
@ -28,6 +29,10 @@ func NewConfig(filepath string) (*Config, error) {
return &cfg, err
}
if cfg.SlackToken == "" {
return &cfg, errors.New("couldn't find 'slack_token' parameter")
}
if cfg.Theme == "light" {
termui.ColorMap = map[string]termui.Attribute{
"fg": termui.ColorBlack,

View File

@ -29,7 +29,7 @@ func CreateAppContext(flgConfig string) *AppContext {
// Load config
config, err := config.NewConfig(flgConfig)
if err != nil {
log.Fatalf("ERROR: not able to load config file: %s", flgConfig)
log.Fatalf("ERROR: not able to load config file (%s): %s", flgConfig, err)
}
// Create Service