37 lines
861 B
Go
37 lines
861 B
Go
|
package flags
|
||
|
|
||
|
import "flag"
|
||
|
|
||
|
func (flags *Flags) ParseFlags() (err error) {
|
||
|
|
||
|
// Define parameters
|
||
|
flag.StringVar(&flags.Vars.Role, "role", "scheduler", "Role of the instance ['scheduler','agent']")
|
||
|
flag.StringVar(&flags.Vars.Address, "address", "127.0.0.1", "Address of the instance to listen to/connect to")
|
||
|
flag.IntVar(&flags.Vars.Port, "port", 8080, "Port of the instance to listen on/connect to")
|
||
|
flag.IntVar(&flags.Vars.NumCPUs, "numcpus", 1, "[agent] Number of CPUs to use")
|
||
|
|
||
|
// Parse the flags
|
||
|
flag.Parse()
|
||
|
|
||
|
// Parse the role parameters
|
||
|
err = flags.parseRole()
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
/// Parse the number of CPUs parameters
|
||
|
err = flags.parseNumCPUs()
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
// Parse the address and port parameters
|
||
|
err = flags.parseAddressPort()
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
// Return nil if no errors
|
||
|
return
|
||
|
}
|