-
Notifications
You must be signed in to change notification settings - Fork 3
/
options.go
33 lines (30 loc) · 790 Bytes
/
options.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
package sendkeys
// KBOpt are options for our wrapper
type KBOpt uint8
const (
// Stubborn will cause our sequences to continue despite errors.
// Otherwise, we will stop if our error count is over 0.
Stubborn KBOpt = iota
// Noisy will cause all errors to be printed to stdout.
Noisy
// Random will use random sleeps throughout the typing process.
// Otherwise, a static 10 milliseconds will be used.
Random
// NoDelay will bypass the 2 second delay for linux, mostly for testing.
NoDelay
)
func (kb *KBWrap) processOptions(opts ...KBOpt) {
kbo := map[KBOpt]*bool{
Stubborn: &kb.stubborn,
Noisy: &kb.noisy,
Random: &kb.random,
NoDelay: &kb.nodelay,
}
for _, o := range opts {
if option, ok := kbo[o]; !ok {
continue
} else {
*option = true
}
}
}