package main

import (
	"fmt"
	"os"

	"gitea.ligthert.net/golang/sfcs/client"
	"gitea.ligthert.net/golang/sfcs/flags"
	"gitea.ligthert.net/golang/sfcs/server"
	"gitea.ligthert.net/golang/sfcs/vars"
)

func main() {

	// Create a new instance of the Controller struct
	vars := vars.Vars{}

	// Create a new instance of the Flags struct
	flags := flags.Flags{Vars: &vars}
	err := flags.ParseFlags()
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	// Switch on the role
	switch vars.Role {
	case "scheduler":
		server := server.Server{ListenAddress: vars.Address, ListenPort: vars.Port, Agents: make(map[string]*server.Agent)}
		vars.Operator = &server
	case "agent":
		client := client.Client{ServerAddress: vars.Address, ServerPort: vars.Port}
		vars.Operator = &client
	}

	vars.Operator.Start()

}
