diff --git a/configuration.go b/configuration.go index b4486d1..0559fcc 100644 --- a/configuration.go +++ b/configuration.go @@ -42,10 +42,9 @@ func LoadConfiguration(path string) (conf *Configuration, err error) { conf.IndentedOutput = v case "processes": if kv[1] != "" { - conf.Processes = strings.Split(kv[1], " ") + conf.Processes = append(conf.Processes, strings.Split(kv[1], " ")...) } else { log.Printf("WARN: \"processes\" list is empty.\n") - conf.Processes = []string{} } } } @@ -73,8 +72,8 @@ func (conf *Configuration) StoreConfiguration(path string) (err error) { return nil } -// AddProcessToList appends a new given process into a configuration file. -func (conf *Configuration) AddProcessToList(process string, configPath string) error { +// AddProcess appends a new given process into a configuration file. +func (conf *Configuration) AddProcess(process string, configPath string) error { for _, v := range conf.Processes { if v == process { return ErrIsOnList @@ -82,24 +81,16 @@ func (conf *Configuration) AddProcessToList(process string, configPath string) e } conf.Processes = append(conf.Processes, process) - if err := conf.StoreConfiguration(configPath); err != nil { - return err - } - return nil } -// RemoveProcessFromList removes a given process from a configuration file. -func (conf *Configuration) RemoveProcessFromList(process string, configPath string) error { +// RemoveProcess removes a given process from a configuration file. +func (conf *Configuration) RemoveProcess(process string, configPath string) error { for k, v := range conf.Processes { if v == process { newlist := make([]string, len(conf.Processes)-1) newlist = append(conf.Processes[:k], conf.Processes[k+1:]...) conf.Processes = newlist - if err := conf.StoreConfiguration(configPath); err != nil { - return err - } - return nil } }