// modify executes the requested changes func (c *Command) modify() bool { effective := false cnf := configuration.Config for _, n := range c.toStart.Commands { if _, ok := plugins.Commands[n]; ok { cnf.Commands = append(cnf.Commands, n) effective = true } } for _, n := range c.toStart.Middlewares { if _, ok := plugins.Middlewares[n]; ok { cnf.Middlewares = append(cnf.Middlewares, n) effective = true } } for _, n := range c.toStop.Commands { if _, ok := plugins.Commands[n]; ok && utils.StringInSlice(n, cnf.Commands) { cnf.Commands, _ = utils.RemoveStringInSlice(n, cnf.Commands) plugins.Commands[n].Stop() effective = true } } for _, n := range c.toStop.Middlewares { if _, ok := plugins.Middlewares[n]; ok && utils.StringInSlice(n, cnf.Middlewares) { cnf.Middlewares, _ = utils.RemoveStringInSlice(n, cnf.Middlewares) plugins.Middlewares[n].Stop() effective = true } } plugins.Start() return effective }
func (c *Command) admins() bool { var effective = false cnf := configuration.Config for _, i := range c.args[1:] { if strings.HasPrefix(i, "-") { cnf.Admins, _ = utils.RemoveStringInSlice(i[1:], cnf.Admins) effective = true } else if strings.HasPrefix(i, "+") && !utils.StringInSlice(i[1:], cnf.Admins) { cnf.Admins = append(cnf.Admins, i[1:]) effective = true } } return effective }