From 97439561ee4b15e8b91345f6e639be4a8ed8b193 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sat, 16 Dec 2023 02:22:27 +0400 Subject: [PATCH] Added a check for an empty process field. Also, added ability to leave just a process name that will be an alias simultaneously. --- configuration.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/configuration.go b/configuration.go index 81a15d5..d2c6a46 100644 --- a/configuration.go +++ b/configuration.go @@ -2,6 +2,7 @@ package main import ( "encoding/json" + "fmt" "os" ) @@ -23,5 +24,15 @@ func LoadConfiguration(path string) (conf *Configuration, err error) { return nil, err } + for i := 0; i < len(conf.Processes); i++ { + if conf.Processes[i].Process == "" { + return nil, fmt.Errorf("an empty process field found") + } + + if conf.Processes[i].Alias == "" { + conf.Processes[i].Alias = conf.Processes[i].Process + } + } + return conf, nil }