From 04d286d7bcecc97ca3316f1f58958ba90f5a723b Mon Sep 17 00:00:00 2001 From: Jacob Bednarz Date: Mon, 19 Oct 2020 10:18:05 +1100 Subject: [PATCH] exec: Check for config file before trying to use it (#16) Updates the `exec` flow to check the `config` file exists before attempting to pull data from it. Fixes #12 --- cmd/exec.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/exec.go b/cmd/exec.go index 08b3c99..1543c98 100644 --- a/cmd/exec.go +++ b/cmd/exec.go @@ -60,7 +60,12 @@ var execCmd = &cobra.Command{ if err != nil { log.Fatal("unable to find home directory: ", err) } + cfg, err := ini.Load(home + defaultFullConfigPath) + if err != nil { + log.Fatal("unable to use configuration file: ", err) + } + profileSection, err := cfg.GetSection("profile " + profileName) if err != nil { log.Fatal("unable to find profile: ", err)