-
Notifications
You must be signed in to change notification settings - Fork 3
/
flags.go
50 lines (41 loc) · 1.13 KB
/
flags.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package mpi
import (
"flag"
"fmt"
"strings"
"time"
)
var FlagAddr string
var FlagAllAddrs AddrsFlag
var FlagInitTimeout DurationFlag
var FlagProtocol string
var FlagPassword string
type AddrsFlag []string
func (m *AddrsFlag) String() string {
return fmt.Sprint(*m)
}
func (m *AddrsFlag) Set(value string) error {
for _, str := range strings.Split(value, ",") {
*m = append(*m, str)
}
return nil
}
type DurationFlag time.Duration
func (m *DurationFlag) String() string {
return time.Duration(*m).String()
}
func (m *DurationFlag) Set(value string) error {
dur, err := time.ParseDuration(value)
if err != nil {
return err
}
*m = DurationFlag(dur)
return nil
}
func init() {
flag.StringVar(&FlagAddr, "mpi-addr", "", "address of the local running process")
flag.Var(&FlagAllAddrs, "mpi-alladdr", "addresses of all of the processes as comma separated values")
flag.Var(&FlagInitTimeout, "mpi-inittimeout", "duration to wait before timeout in init")
flag.StringVar(&FlagProtocol, "mpi-protocol", "tcp", "communication protocol to use")
flag.StringVar(&FlagPassword, "mpi-password", "", "value to use for salting the mpi connection")
}