Merge pull request #26 from ghaabor/slack-token-name-check

Check for slack_token parameter before launch
This commit is contained in:
JP Bruins Slot 2016-10-18 19:00:03 +02:00 committed by GitHub
commit 14d2fc5a7f
3 changed files with 7 additions and 2 deletions

View File

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

View File

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

View File

@ -29,7 +29,7 @@ func CreateAppContext(flgConfig string) *AppContext {
// Load config // Load config
config, err := config.NewConfig(flgConfig) config, err := config.NewConfig(flgConfig)
if err != nil { 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 // Create Service