From 43ea994b9e7b47be91f0f30eccf33bdbeeafac99 Mon Sep 17 00:00:00 2001 From: Gabor Takacs Date: Tue, 18 Oct 2016 17:55:37 +0200 Subject: [PATCH] Check for slack_token parameter before launch --- README.md | 2 +- src/config/config.go | 5 +++++ src/context/context.go | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 14b525a..61d8d05 100644 --- a/README.md +++ b/README.md @@ -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" diff --git a/src/config/config.go b/src/config/config.go index 8227f40..7b63d2a 100644 --- a/src/config/config.go +++ b/src/config/config.go @@ -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, diff --git a/src/context/context.go b/src/context/context.go index 0a75b37..c65004d 100644 --- a/src/context/context.go +++ b/src/context/context.go @@ -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