Make default slack-term config file a dotfile

Fixes #118, #127
This commit is contained in:
erroneousboat 2018-03-23 12:49:23 +01:00
parent cae6a9a662
commit ad04a301ec
2 changed files with 4 additions and 3 deletions

View File

@ -3,6 +3,7 @@ package config
import (
"encoding/json"
"errors"
"fmt"
"os"
"github.com/erroneousboat/termui"
@ -25,11 +26,11 @@ func NewConfig(filepath string) (*Config, error) {
file, err := os.Open(filepath)
if err != nil {
return &cfg, err
return &cfg, fmt.Errorf("couldn't find the slack-term config file: %v", err)
}
if err := json.NewDecoder(file).Decode(&cfg); err != nil {
return &cfg, err
return &cfg, fmt.Errorf("the slack-term config file isn't valid json: %v", err)
}
if cfg.SlackToken == "" {

View File

@ -51,7 +51,7 @@ func init() {
flag.StringVar(
&flgConfig,
"config",
path.Join(usr.HomeDir, "slack-term.json"),
path.Join(usr.HomeDir, ".slack-term"),
"location of config file",
)