// Execute starts/stops a service
Execute starts/stops a service
// Execute starts / stops a service
func (service *Service) Execute() (result model.Result) {
	fmt.Println(service.Description)
	switch service.Action {
	case "start":
		if err := startService(service.Name); err != nil {
			result.WasSuccessful = false
			result.Message = err.Error()
		} else {
			result.WasSuccessful = true
			result.Message = "Service \"" + service.Name + "\" started"
		}
		return result
	case "stop":
		if err := stopService(service.Name); err != nil {
			result.WasSuccessful = false
			result.Message = err.Error()
		} else {
			result.WasSuccessful = true
			result.Message = "Service \"" + service.Name + "\" stopped"
		}
		return result
	default:
		result.WasSuccessful = false
		result.Message = fmt.Sprintf("unknown action of type %s", service.Action)
		return result
	}
}
func ( service * Service ) Execute ( ) ( result model . Result ) { fmt . Println ( service . Description ) switch service . Action { case " " : if err := startService ( service . Name ) ; err != nil { result . WasSuccessful = false result . Message = err . Error ( ) } else { result . WasSuccessful = true result . Message = " \" " + service . Name + " \" " } return result case " " : if err := stopService ( service . Name ) ; err != nil { result . WasSuccessful = false result . Message = err . Error ( ) } else { result . WasSuccessful = true result . Message = " \" " + service . Name + " \" " } return result default : result . WasSuccessful = false result . Message = fmt . Sprintf ( " " , service . Action ) return result } }
Execute starts/stops a service
Execute starts / stops a service